Class: Finlight::RawArticle

Inherits:
Object
  • Object
show all
Defined in:
lib/finlight/models.rb

Overview

An unenriched article as delivered by the raw stream.

Direct Known Subclasses

Article

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(link:, title:, publish_date:, source:, language:, summary: nil, images: nil, created_at: nil, revised_date: nil, is_update: nil, categories: nil) ⇒ RawArticle

Returns a new instance of RawArticle.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/finlight/models.rb', line 88

def initialize(link:, title:, publish_date:, source:, language:, summary: nil, images: nil,
               created_at: nil, revised_date: nil, is_update: nil, categories: nil, **)
  @link = link
  @title = title
  @publish_date = publish_date
  @source = source
  @language = language
  @summary = summary
  @images = images
  @created_at = created_at
  @revised_date = revised_date
  @is_update = is_update
  @categories = categories
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



85
86
87
# File 'lib/finlight/models.rb', line 85

def categories
  @categories
end

#created_atObject (readonly)

Returns the value of attribute created_at.



85
86
87
# File 'lib/finlight/models.rb', line 85

def created_at
  @created_at
end

#imagesObject (readonly)

Returns the value of attribute images.



85
86
87
# File 'lib/finlight/models.rb', line 85

def images
  @images
end

#is_updateObject (readonly)

Returns the value of attribute is_update.



85
86
87
# File 'lib/finlight/models.rb', line 85

def is_update
  @is_update
end

#languageObject (readonly)

Returns the value of attribute language.



85
86
87
# File 'lib/finlight/models.rb', line 85

def language
  @language
end

Returns the value of attribute link.



85
86
87
# File 'lib/finlight/models.rb', line 85

def link
  @link
end

#publish_dateObject (readonly)

Returns the value of attribute publish_date.



85
86
87
# File 'lib/finlight/models.rb', line 85

def publish_date
  @publish_date
end

#revised_dateObject (readonly)

Returns the value of attribute revised_date.



85
86
87
# File 'lib/finlight/models.rb', line 85

def revised_date
  @revised_date
end

#sourceObject (readonly)

Returns the value of attribute source.



85
86
87
# File 'lib/finlight/models.rb', line 85

def source
  @source
end

#summaryObject (readonly)

Returns the value of attribute summary.



85
86
87
# File 'lib/finlight/models.rb', line 85

def summary
  @summary
end

#titleObject (readonly)

Returns the value of attribute title.



85
86
87
# File 'lib/finlight/models.rb', line 85

def title
  @title
end

Class Method Details

.base_attributes(hash) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/finlight/models.rb', line 103

def self.base_attributes(hash)
  {
    link: hash["link"],
    title: hash["title"],
    publish_date: FlexTime.parse(hash["publishDate"]),
    source: hash["source"],
    language: hash["language"],
    summary: hash["summary"],
    images: ModelParsing.to_string_list(hash["images"]),
    created_at: FlexTime.parse(hash["createdAt"]),
    revised_date: FlexTime.parse(hash["revisedDate"]),
    is_update: hash["isUpdate"],
    categories: ModelParsing.to_string_list(hash["categories"])
  }
end

.from_h(hash) ⇒ Object



119
120
121
# File 'lib/finlight/models.rb', line 119

def self.from_h(hash)
  new(**base_attributes(hash))
end