Finance::Bitcoin::Feed::Site - Base class of Finance::Bitcoin::Feed::Site::* modules
use Mojo::Base 'Finance::Bitcoin::Feed::Site'; has site => 'SITENAME'; sub go{ my $self = shift; #Dont' forget this line: $self->SUPER::go(); # connect the site # parse the data # and emit the data by call $self->emit('data_out', $currency, $price); }
It is a base class. It set some helper attributes and methods, and have an timer event that can restart the connection. You just need to override the method 'go' to connect to the site.
This class inherits all attributes from Mojo::EventEmitter and add the following new ones:
The time that the object receive the data from the server. It is mainly updated by the method 'on_data_out'
if time() - last_activity_at > last_activity_period, then we think the site is disconnected.
The timer event to restart the connection
The tag that shows the site is running.
The site name which will be print in the debug information.
Create object and set some events and timer
the callback which will be called when receive the event 'data_out'. It will Then emit the event 'output'
The args of event data_out is:
my ($self, $timestamp, $site, $currency, $price) = @_;
The unit of timestamp is ms.
The callback called by timer. It will emit event 'timeout' when timeout.
The callback of event 'timeout'. It will call method 'go' to restart the connection
Establish the connection.
Print debug information if the envrionment variable 'FINANCE_BITCOIN_FEED_DEBUG' is set to true.
Print error information if there is error.
This class inherits all events from Mojo::EventEmitter and add the following new ones:
It will be emitted by the site module when the site module want to output the data.
It will be emit by this module when print out the data. You can listen on this event to get the output.
It will be emit when the timer watch that the connection is timeout
Mojo::EventEmitter
Finance::Bitcoin::Feed
Chylli <chylli@binary.com>
<chylli@binary.com>
To install Finance::Bitcoin::Feed, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::Bitcoin::Feed
CPAN shell
perl -MCPAN -e shell install Finance::Bitcoin::Feed
For more information on module installation, please visit the detailed CPAN module installation guide.