Class: Html2rss::FeedBuilder::JsonFeed
- Inherits:
-
Object
- Object
- Html2rss::FeedBuilder::JsonFeed
- 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
-
#call ⇒ Hash
Builds and returns the JSONFeed hash.
-
#initialize(channel:, articles:, user_comment:, feed_url: nil) ⇒ JsonFeed
constructor
A new instance of JsonFeed.
Constructor Details
#initialize(channel:, articles:, user_comment:, feed_url: nil) ⇒ JsonFeed
Returns a new instance of JsonFeed.
18 19 20 21 22 23 24 25 |
# File 'lib/html2rss/feed_builder/json_feed.rb', line 18 def initialize(channel:, articles:, user_comment:, feed_url: nil) raise ArgumentError, 'user_comment must be a non-blank String' if blank_string?(user_comment) @channel = channel @articles = articles @feed_url = normalize_feed_url(feed_url) @user_comment = user_comment end |
Instance Method Details
#call ⇒ Hash
Builds and returns the JSONFeed hash.
31 32 33 |
# File 'lib/html2rss/feed_builder/json_feed.rb', line 31 def call base_payload.merge(authors: , items: item_hashes).compact end |