Class: Ruboty::Rss::Feed
- Inherits:
-
Object
- Object
- Ruboty::Rss::Feed
- Defined in:
- lib/ruboty/rss/feed.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #from ⇒ Object
- #id ⇒ Object
-
#initialize(attributes) ⇒ Feed
constructor
A new instance of Feed.
- #new_items ⇒ Object
- #to ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Feed
Returns a new instance of Feed.
8 9 10 |
# File 'lib/ruboty/rss/feed.rb', line 8 def initialize(attributes) @attributes = attributes.stringify_keys end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/ruboty/rss/feed.rb', line 6 def attributes @attributes end |
Instance Method Details
#from ⇒ Object
20 21 22 |
# File 'lib/ruboty/rss/feed.rb', line 20 def from attributes['from'] end |
#id ⇒ Object
12 13 14 |
# File 'lib/ruboty/rss/feed.rb', line 12 def id attributes['id'] end |
#new_items ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruboty/rss/feed.rb', line 28 def new_items source = open(url) {|f| f.read } rss = RSS::Parser.parse(source) items = [] if @last_links items = rss.items.reject do |item| @last_links.include?(item.link) end end @last_links = rss.items.map {|item| item.link } items end |
#to ⇒ Object
24 25 26 |
# File 'lib/ruboty/rss/feed.rb', line 24 def to attributes['to'] end |
#url ⇒ Object
16 17 18 |
# File 'lib/ruboty/rss/feed.rb', line 16 def url attributes['url'] end |