Class: Hootenanny::Feed::JSONFeed
Constant Summary
FEED_TYPE_MAPPINGS
Instance Method Summary
collapse
#+, #-, #empty?, from_content, infer, #to_digest_feed, #type
Instance Method Details
#content ⇒ Object
25
26
27
|
# File 'lib/hootenanny/feed/json_feed.rb', line 25
def content
@content
end
|
#content=(content) ⇒ Object
29
30
31
32
33
|
# File 'lib/hootenanny/feed/json_feed.rb', line 29
def content=(content)
@content = coerce_content(content)
rescue JSON::ParserError => e
raise Hootenanny::Feed::ParseError.wrap(e)
end
|
#content_type ⇒ Object
13
14
15
|
# File 'lib/hootenanny/feed/json_feed.rb', line 13
def content_type
'application/json'
end
|
#items ⇒ Object
9
10
11
|
# File 'lib/hootenanny/feed/json_feed.rb', line 9
def items
@items ||= content.fetch('items', []).map { |i| Hootenanny::Feed::JSONFeedItem.new i }
end
|
#to_s ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/hootenanny/feed/json_feed.rb', line 17
def to_s
@to_s ||= -> do
content['items'] = items.map(&:content)
JSON.dump(content)
end.call
end
|