class Feedjira::Parser::JSONFeedItem
Attributes
Public Class Methods
Source
# File lib/feedjira/parser/json_feed_item.rb, line 12 def initialize(json) @json = json @entry_id = json.fetch("id") @url = json.fetch("url") @external_url = json.fetch("external_url", nil) @title = json.fetch("title", nil) @content = parse_content(json.fetch("content_html", nil), json.fetch("content_text", nil)) @summary = json.fetch("summary", nil) @image = json.fetch("image", nil) @banner_image = json.fetch("banner_image", nil) @published = parse_published(json.fetch("date_published", nil)) @updated = parse_updated(json.fetch("date_modified", nil)) @author = author_name(json.fetch("author", nil)) @categories = json.fetch("tags", []) end
Private Instance Methods
Source
# File lib/feedjira/parser/json_feed_item.rb, line 44 def parse_content(content_html, content_text) return content_html unless content_html.nil? content_text end
Convenience method to return the included content type. Prefer content_html unless it isn’t included.
Source
# File lib/feedjira/parser/json_feed_item.rb, line 30 def parse_published(date_published) return nil unless date_published Time.parse_safely(date_published) end
Source
# File lib/feedjira/parser/json_feed_item.rb, line 36 def parse_updated(date_modified) return nil unless date_modified Time.parse_safely(date_modified) end