Class: Finlight::Company

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

Overview

A company tagged in an article.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(company_id:, name:, ticker:, confidence: nil, country: nil, exchange: nil, industry: nil, sector: nil, isin: nil, openfigi: nil, primary_listing: nil, isins: nil, other_listings: nil) ⇒ Company

Returns a new instance of Company.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/finlight/models.rb', line 46

def initialize(company_id:, name:, ticker:, confidence: nil, country: nil, exchange: nil,
               industry: nil, sector: nil, isin: nil, openfigi: nil, primary_listing: nil,
               isins: nil, other_listings: nil)
  @company_id = company_id
  @confidence = confidence
  @country = country
  @exchange = exchange
  @industry = industry
  @sector = sector
  @name = name
  @ticker = ticker
  @isin = isin
  @openfigi = openfigi
  @primary_listing = primary_listing
  @isins = isins
  @other_listings = other_listings
end

Instance Attribute Details

#company_idObject (readonly)

Returns the value of attribute company_id.



43
44
45
# File 'lib/finlight/models.rb', line 43

def company_id
  @company_id
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



43
44
45
# File 'lib/finlight/models.rb', line 43

def confidence
  @confidence
end

#countryObject (readonly)

Returns the value of attribute country.



43
44
45
# File 'lib/finlight/models.rb', line 43

def country
  @country
end

#exchangeObject (readonly)

Returns the value of attribute exchange.



43
44
45
# File 'lib/finlight/models.rb', line 43

def exchange
  @exchange
end

#industryObject (readonly)

Returns the value of attribute industry.



43
44
45
# File 'lib/finlight/models.rb', line 43

def industry
  @industry
end

#isinObject (readonly)

Returns the value of attribute isin.



43
44
45
# File 'lib/finlight/models.rb', line 43

def isin
  @isin
end

#isinsObject (readonly)

Returns the value of attribute isins.



43
44
45
# File 'lib/finlight/models.rb', line 43

def isins
  @isins
end

#nameObject (readonly)

Returns the value of attribute name.



43
44
45
# File 'lib/finlight/models.rb', line 43

def name
  @name
end

#openfigiObject (readonly)

Returns the value of attribute openfigi.



43
44
45
# File 'lib/finlight/models.rb', line 43

def openfigi
  @openfigi
end

#other_listingsObject (readonly)

Returns the value of attribute other_listings.



43
44
45
# File 'lib/finlight/models.rb', line 43

def other_listings
  @other_listings
end

#primary_listingObject (readonly)

Returns the value of attribute primary_listing.



43
44
45
# File 'lib/finlight/models.rb', line 43

def primary_listing
  @primary_listing
end

#sectorObject (readonly)

Returns the value of attribute sector.



43
44
45
# File 'lib/finlight/models.rb', line 43

def sector
  @sector
end

#tickerObject (readonly)

Returns the value of attribute ticker.



43
44
45
# File 'lib/finlight/models.rb', line 43

def ticker
  @ticker
end

Class Method Details

.from_h(hash) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/finlight/models.rb', line 64

def self.from_h(hash)
  new(
    company_id: hash["companyId"],
    confidence: ModelParsing.to_float(hash["confidence"]),
    country: hash["country"],
    exchange: hash["exchange"],
    industry: hash["industry"],
    sector: hash["sector"],
    name: hash["name"],
    ticker: hash["ticker"],
    isin: hash["isin"],
    openfigi: hash["openfigi"],
    primary_listing: hash["primaryListing"] && Listing.from_h(hash["primaryListing"]),
    isins: ModelParsing.to_string_list(hash["isins"]),
    other_listings: hash["otherListings"]&.map { |l| Listing.from_h(l) }
  )
end