Class: StreamBot::Tracker
- Inherits:
-
Object
- Object
- StreamBot::Tracker
- Extended by:
- EventHandler
- Defined in:
- lib/streambot/tracker.rb
Overview
The Tracker class that provides a start and a stop method This class has serveral callback methods
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(params) ⇒ Tracker
constructor
initializes the tracker.
-
#start ⇒ Object
start the tracker.
-
#stop ⇒ Object
stop the tracker.
Methods included from EventHandler
Constructor Details
#initialize(params) ⇒ Tracker
initializes the tracker
11 12 13 14 15 16 17 18 19 |
# File 'lib/streambot/tracker.rb', line 11 def initialize(params) self.params = params @retweet = StreamBot::Retweet.new(self.params) @client = TwiStream::Client.new(authentication) @client.on_error.handle do |msg, trace| LOG.error "#{msg}" on_error.trigger(msg, trace) end end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
8 9 10 |
# File 'lib/streambot/tracker.rb', line 8 def auth @auth end |
#params ⇒ Object
Returns the value of attribute params.
8 9 10 |
# File 'lib/streambot/tracker.rb', line 8 def params @params end |
Instance Method Details
#start ⇒ Object
start the tracker
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/streambot/tracker.rb', line 22 def start keywords = self.params["keywords"] @thread = Thread.new do @client.filter_by_keywords(keywords) do |status| if retweet?(status) before_retweet.trigger(status) @retweet.retweet(status["id"]) after_retweet.trigger(status) end end end @thread.join end |
#stop ⇒ Object
stop the tracker
37 38 39 |
# File 'lib/streambot/tracker.rb', line 37 def stop @client.stop end |