Class: Html2rss::JsonFeedBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/json_feed_builder.rb,
lib/html2rss/json_feed_builder/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:) ⇒ JsonFeedBuilder

Returns a new instance of JsonFeedBuilder.

Parameters:



15
16
17
18
# File 'lib/html2rss/json_feed_builder.rb', line 15

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



24
25
26
# File 'lib/html2rss/json_feed_builder.rb', line 24

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