Class: Ruboty::Rss::Feed

Inherits:
Object
  • Object
show all
Defined in:
lib/ruboty/rss/feed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (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

#fromObject



20
21
22
# File 'lib/ruboty/rss/feed.rb', line 20

def from
  attributes['from']
end

#idObject



12
13
14
# File 'lib/ruboty/rss/feed.rb', line 12

def id
  attributes['id']
end

#new_itemsObject



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

#toObject



24
25
26
# File 'lib/ruboty/rss/feed.rb', line 24

def to
  attributes['to']
end

#urlObject



16
17
18
# File 'lib/ruboty/rss/feed.rb', line 16

def url
  attributes['url']
end