Class: Html2rss::FeedBuilder::JsonFeed

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

Overview

Builds a JSONFeed 1.1 hash from channel metadata and articles.

Defined Under Namespace

Classes: Item

Constant Summary collapse

VERSION_URL =

Official JSON Feed 1.1 schema version URL.

'https://jsonfeed.org/version/1.1'

Instance Method Summary collapse

Constructor Details

#initialize(channel:, articles:) ⇒ JsonFeed

Returns a new instance of JsonFeed.

Parameters:



16
17
18
19
# File 'lib/html2rss/feed_builder/json_feed.rb', line 16

def initialize(channel:, articles:)
  @channel = channel
  @articles = articles
end

Instance Method Details

#callHash

Builds and returns the JSONFeed hash.

Returns:

  • (Hash)

    the JSONFeed-compliant hash



25
26
27
# File 'lib/html2rss/feed_builder/json_feed.rb', line 25

def call
  base_payload.merge(authors: author_array, items: item_hashes).compact
end