Class: Html2rss::FeedBuilder::JsonFeed::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/feed_builder/json_feed/item.rb

Overview

Maps an Article to a JSONFeed 1.1 item hash.

Instance Method Summary collapse

Constructor Details

#initialize(article) ⇒ Item

Returns a new instance of Item.

Parameters:



11
12
13
# File 'lib/html2rss/feed_builder/json_feed/item.rb', line 11

def initialize(article)
  @article = article
end

Instance Method Details

#to_hHash?

Returns the JSONFeed-compliant item hash.

Returns:

  • (Hash, nil)

    the JSONFeed-compliant item hash



17
18
19
20
21
22
# File 'lib/html2rss/feed_builder/json_feed/item.rb', line 17

def to_h
  content = content_fields
  return if content.empty?

  item_payload.merge(content).compact
end