Class: Everyx::PeriodicTasks::RSSNotifier
- Inherits:
-
Object
- Object
- Everyx::PeriodicTasks::RSSNotifier
- Defined in:
- lib/everyx.rb
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize ⇒ RSSNotifier
constructor
A new instance of RSSNotifier.
- #run ⇒ Object
Constructor Details
#initialize ⇒ RSSNotifier
Returns a new instance of RSSNotifier.
34 35 36 37 |
# File 'lib/everyx.rb', line 34 def initialize @uri, @delay = nil, ( 60 * 15 ) @last = nil end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
32 33 34 |
# File 'lib/everyx.rb', line 32 def delay @delay end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
31 32 33 |
# File 'lib/everyx.rb', line 31 def uri @uri end |
Instance Method Details
#run ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/everyx.rb', line 39 def run rss = RSS::Parser.parse( open(@uri) {|s| s.read }, false ) new = [] first_new = nil rss.items.each do |item| if item.link != @last first_new = item.link unless first_new new << item.title else break end end @last = first_new if first_new if new.size > 0 puts "#{new.size} items" NServer::Client.try_notify( new.join("\n") ) else puts "No new items." end end |