Class: SimpleRSS::NormalizedEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/simple-rss/normalized_entry.rb

Overview

rbs_inline: enabled

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ NormalizedEntry

Returns a new instance of NormalizedEntry.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/simple-rss/normalized_entry.rb', line 16

def initialize(attributes)
  values = immutable_copy(attributes)
  empty_categories = [] #: Array[String]
  empty_records = [] #: Array[Hash[Symbol, untyped]]
  empty_data = {} #: Hash[Symbol, untyped]
  empty_categories.freeze
  empty_records.freeze
  empty_data.freeze
  @external_url = values[:external_url]
  @image = values[:image]
  @banner_image = values[:banner_image]
  @language = values[:language]
  @identifier = values[:identifier]
  @url = values[:url]
  @title = values[:title]
  @published_at = values[:published_at]
  @updated_at = values[:updated_at]
  @content_html = values[:content_html]
  @content_text = values[:content_text]
  @content_url = values[:content_url]
  @content_base_url = values[:content_base_url]
  @summary = values[:summary]
  @summary_type = values[:summary_type]
  @categories = values.fetch(:categories, empty_categories)
  @category_details = values.fetch(:category_details, empty_records)
  @attachments = values.fetch(:attachments, empty_records)
  @links = values.fetch(:links, empty_records)
  @authors = values.fetch(:authors, empty_records)
  @issues = values.fetch(:issues, empty_records)
  @raw = values.fetch(:raw, empty_data)
  @raw_xml = values[:raw_xml]
  @field_sources = values.fetch(:field_sources, empty_data)
  freeze
end

Instance Attribute Details

#attachmentsObject (readonly)

: Array[Hash[Symbol, untyped]]



10
11
12
# File 'lib/simple-rss/normalized_entry.rb', line 10

def attachments
  @attachments
end

#authorsObject (readonly)

: Array[Hash[Symbol, untyped]]



10
11
12
# File 'lib/simple-rss/normalized_entry.rb', line 10

def authors
  @authors
end

: String?



4
5
6
# File 'lib/simple-rss/normalized_entry.rb', line 4

def banner_image
  @banner_image
end

#categoriesObject (readonly)

: Array



9
10
11
# File 'lib/simple-rss/normalized_entry.rb', line 9

def categories
  @categories
end

#category_detailsObject (readonly)

: Array[Hash[Symbol, untyped]]



10
11
12
# File 'lib/simple-rss/normalized_entry.rb', line 10

def category_details
  @category_details
end

#content_base_urlObject (readonly)

: String?



7
8
9
# File 'lib/simple-rss/normalized_entry.rb', line 7

def content_base_url
  @content_base_url
end

#content_htmlObject (readonly)

: String?



7
8
9
# File 'lib/simple-rss/normalized_entry.rb', line 7

def content_html
  @content_html
end

#content_textObject (readonly)

: String?



7
8
9
# File 'lib/simple-rss/normalized_entry.rb', line 7

def content_text
  @content_text
end

#content_urlObject (readonly)

: String?



7
8
9
# File 'lib/simple-rss/normalized_entry.rb', line 7

def content_url
  @content_url
end

#external_urlObject (readonly)

: String?



4
5
6
# File 'lib/simple-rss/normalized_entry.rb', line 4

def external_url
  @external_url
end

#field_sourcesObject (readonly)

: Hash[Symbol, untyped]



12
13
14
# File 'lib/simple-rss/normalized_entry.rb', line 12

def field_sources
  @field_sources
end

#identifierObject (readonly)

: String?



5
6
7
# File 'lib/simple-rss/normalized_entry.rb', line 5

def identifier
  @identifier
end

#imageObject (readonly)

: String?



4
5
6
# File 'lib/simple-rss/normalized_entry.rb', line 4

def image
  @image
end

#issuesObject (readonly)

: Array[Hash[Symbol, untyped]]



10
11
12
# File 'lib/simple-rss/normalized_entry.rb', line 10

def issues
  @issues
end

#languageObject (readonly)

: String?



4
5
6
# File 'lib/simple-rss/normalized_entry.rb', line 4

def language
  @language
end

: Array[Hash[Symbol, untyped]]



10
11
12
# File 'lib/simple-rss/normalized_entry.rb', line 10

def links
  @links
end

#published_atObject (readonly)

: Time?



6
7
8
# File 'lib/simple-rss/normalized_entry.rb', line 6

def published_at
  @published_at
end

#rawObject (readonly)

: Hash[Symbol | String, untyped]



11
12
13
# File 'lib/simple-rss/normalized_entry.rb', line 11

def raw
  @raw
end

#raw_xmlObject (readonly)

: String?



13
14
15
# File 'lib/simple-rss/normalized_entry.rb', line 13

def raw_xml
  @raw_xml
end

#summaryObject (readonly)

: String?



7
8
9
# File 'lib/simple-rss/normalized_entry.rb', line 7

def summary
  @summary
end

#summary_typeObject (readonly)

: Symbol?



8
9
10
# File 'lib/simple-rss/normalized_entry.rb', line 8

def summary_type
  @summary_type
end

#titleObject (readonly)

: String?



5
6
7
# File 'lib/simple-rss/normalized_entry.rb', line 5

def title
  @title
end

#updated_atObject (readonly)

: Time?



6
7
8
# File 'lib/simple-rss/normalized_entry.rb', line 6

def updated_at
  @updated_at
end

#urlObject (readonly)

: String?



5
6
7
# File 'lib/simple-rss/normalized_entry.rb', line 5

def url
  @url
end

Instance Method Details

#effective_atObject



52
53
54
# File 'lib/simple-rss/normalized_entry.rb', line 52

def effective_at
  published_at || updated_at
end

#to_hObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/simple-rss/normalized_entry.rb', line 57

def to_h
  {
    external_url: external_url, image: image, banner_image: banner_image, language: language,
    identifier: identifier, url: url, title: title, published_at: published_at, updated_at: updated_at,
    content_html: content_html, content_text: content_text, content_url: content_url, content_base_url: content_base_url,
    summary: summary, summary_type: summary_type, categories: categories, category_details: category_details,
    attachments: attachments, links: links, authors: authors, issues: issues, field_sources: field_sources,
    raw: raw, raw_xml: raw_xml
  }
end