Class: Feedjira::Parser::JSONFeedItem

Inherits:
Object
  • Object
show all
Includes:
FeedEntryUtilities
Defined in:
lib/feedjira/parser/json_feed_item.rb

Overview

Parser for dealing with JSON Feed items.

Constant Summary

Constants included from DateTimeUtilities

DateTimeUtilities::DATE_PARSERS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FeedEntryUtilities

#[], #[]=, #each, #id, #parse_datetime, #published=, #sanitize!, #updated=

Methods included from DateTimeUtilities

#parse_datetime

Constructor Details

#initialize(json) ⇒ JSONFeedItem

Returns a new instance of JSONFeedItem.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def author
  @author
end

Returns the value of attribute banner_image.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def banner_image
  @banner_image
end

#categoriesObject (readonly)

Returns the value of attribute categories.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def categories
  @categories
end

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def content
  @content
end

#entry_idObject (readonly)

Returns the value of attribute entry_id.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def entry_id
  @entry_id
end

#external_urlObject (readonly)

Returns the value of attribute external_url.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def external_url
  @external_url
end

#imageObject (readonly)

Returns the value of attribute image.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def image
  @image
end

#jsonObject (readonly)

Returns the value of attribute json.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def json
  @json
end

#publishedObject (readonly)

Returns the value of attribute published.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def published
  @published
end

#summaryObject (readonly)

Returns the value of attribute summary.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def summary
  @summary
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def title
  @title
end

#updatedObject (readonly)

Returns the value of attribute updated.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def updated
  @updated
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/feedjira/parser/json_feed_item.rb', line 9

def url
  @url
end