Class: Birdy::Base
- Inherits:
-
Object
- Object
- Birdy::Base
- Includes:
- Authentication, ImageDownload
- Defined in:
- lib/birdy/base.rb
Constant Summary
Constants included from ImageDownload
ImageDownload::IMAGES, ImageDownload::ONE_DAY
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #poll ⇒ Object
- #tweets ⇒ Object
Methods included from ImageDownload
Methods included from Authentication
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
11 12 13 14 |
# File 'lib/birdy/base.rb', line 11 def initialize @twitter = authenticate poll end |
Instance Method Details
#poll ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/birdy/base.rb', line 16 def poll @alert = LinuxNotifier.new while true tweets.reverse.each do |tweet| image_path = download(tweet.user.profile_image_url) @alert.show(image_path, tweet.user.name, tweet.text) end sleep 60 end end |
#tweets ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/birdy/base.rb', line 29 def tweets = {} if @last_tweet_id [:since_id] = @last_tweet_id else [:count] = 1 end begin timeline = @twitter.timeline_for(:friends, ) rescue Twitter::RESTError => e puts "Twitter is not responding." + e timeline = [] end if timeline.length > 0 @last_tweet_id = timeline.first.id end timeline end |