Class: Finlight::Article
- Inherits:
-
RawArticle
- Object
- RawArticle
- Finlight::Article
- Defined in:
- lib/finlight/models.rb
Overview
An enriched article with sentiment, entities and content.
Instance Attribute Summary collapse
-
#companies ⇒ Object
readonly
Returns the value of attribute companies.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#countries ⇒ Object
readonly
Returns the value of attribute countries.
-
#sentiment ⇒ Object
readonly
Returns the value of attribute sentiment.
Attributes inherited from RawArticle
#categories, #created_at, #images, #is_update, #language, #link, #publish_date, #revised_date, #source, #summary, #title
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(sentiment: nil, confidence: nil, content: nil, companies: nil, countries: nil, **base) ⇒ Article
constructor
A new instance of Article.
Methods inherited from RawArticle
Constructor Details
#initialize(sentiment: nil, confidence: nil, content: nil, companies: nil, countries: nil, **base) ⇒ Article
Returns a new instance of Article.
128 129 130 131 132 133 134 135 136 |
# File 'lib/finlight/models.rb', line 128 def initialize(sentiment: nil, confidence: nil, content: nil, companies: nil, countries: nil, **base) super(**base) @sentiment = sentiment @confidence = confidence @content = content @companies = companies @countries = countries end |
Instance Attribute Details
#companies ⇒ Object (readonly)
Returns the value of attribute companies.
126 127 128 |
# File 'lib/finlight/models.rb', line 126 def companies @companies end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
126 127 128 |
# File 'lib/finlight/models.rb', line 126 def confidence @confidence end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
126 127 128 |
# File 'lib/finlight/models.rb', line 126 def content @content end |
#countries ⇒ Object (readonly)
Returns the value of attribute countries.
126 127 128 |
# File 'lib/finlight/models.rb', line 126 def countries @countries end |
#sentiment ⇒ Object (readonly)
Returns the value of attribute sentiment.
126 127 128 |
# File 'lib/finlight/models.rb', line 126 def sentiment @sentiment end |
Class Method Details
.from_h(hash) ⇒ Object
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/finlight/models.rb', line 138 def self.from_h(hash) new( **base_attributes(hash), sentiment: hash["sentiment"], confidence: ModelParsing.to_float(hash["confidence"]), content: hash["content"], companies: hash["companies"]&.map { |c| Company.from_h(c) }, countries: ModelParsing.to_string_list(hash["countries"]) ) end |