Class: TweetWatch::Monitor
- Inherits:
-
Object
- Object
- TweetWatch::Monitor
- Defined in:
- lib/tweet_watch/monitor.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Monitor
constructor
A new instance of Monitor.
- #run ⇒ Object
Methods included from Utils
#escape_str, #load_config, #print_dm, #print_tweet
Methods included from Client
Constructor Details
#initialize(options = {}) ⇒ Monitor
Returns a new instance of Monitor.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tweet_watch/monitor.rb', line 12 def initialize( = {}) @options = {interval: (15*60), initial_tweet_history: 200, timeline_count: 200} @options.merge!(Hash[.map{ |k, v| [k.to_sym, v] }]) @options[:interval] = @options[:interval].to_i @new_tweeter_tweets = 0 if TweetWatch.config.tweeters.empty? raise ArgumentError.new("Monitor requires list of target tweeters. Please update config") end if TweetWatch.config.accounts.empty? raise ArgumentError.new("Monitor requires at least one account. Please update config") end @tweeter_state = {} end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tweet_watch/monitor.rb', line 32 def run TweetWatch.config.tweeters.each do |tweeter| record_user_tweets(tweeter) sleep(1) end if @new_tweeter_tweets > 0 TweetWatch.config.accounts.each do |account| record_timeline(account) end end @new_tweeter_tweets = 0 sleep(@options[:interval]) self.run end |