Class: Hootenanny::Feed::RSSFeed

Inherits:
Hootenanny::Feed show all
Defined in:
lib/hootenanny/feed/rss_feed.rb

Direct Known Subclasses

AtomFeed

Constant Summary

Constants inherited from Hootenanny::Feed

FEED_TYPE_MAPPINGS

Instance Method Summary collapse

Methods inherited from Hootenanny::Feed

#+, #-, #empty?, from_content, infer, #to_digest_feed, #type

Instance Method Details

#contentObject



28
29
30
# File 'lib/hootenanny/feed/rss_feed.rb', line 28

def content
  @content
end

#content=(content) ⇒ Object



32
33
34
35
36
# File 'lib/hootenanny/feed/rss_feed.rb', line 32

def content=(content)
  @content = coerce_content(content)
rescue RSS::Error => e
  raise Hootenanny::Feed::ParseError.wrap(e)
end

#content_typeObject



13
14
15
# File 'lib/hootenanny/feed/rss_feed.rb', line 13

def content_type
  'application/rss+xml'
end

#itemsObject



9
10
11
# File 'lib/hootenanny/feed/rss_feed.rb', line 9

def items
  @items ||= content.items.map { |i| Hootenanny::Feed::RSSFeedItem.new i }
end

#to_sObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/hootenanny/feed/rss_feed.rb', line 17

def to_s
  @to_s ||= -> do
    item_string   = items.map { |item| item.content.to_s }.join('')

    feed_string = content.to_s
    feed_string.gsub!(%r{<item>.*</item>}m, item_string)

    feed_string
  end.call
end