Class: ThirteenF::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/thirteen_f/entity.rb

Constant Summary collapse

BASE_URL =
'https://www.sec.gov'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sec_entity) ⇒ Entity

Returns a new instance of Entity.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/thirteen_f/entity.rb', line 22

def initialize(sec_entity)
  @name = sec_entity[:name]
  @cik = cik_from_id sec_entity[:cik]
  @tickers = sec_entity[:tickers]
  @exchanges = sec_entity[:exchanges]
  @sic = sec_entity[:sic]
  @sic_description = sec_entity[:sicDescription]
  @fiscal_year_end = sec_entity[:fiscalYearEnd]
  @business_state_or_country = sec_entity[:addresses][:business][:stateOrCountry]
  @filings = thirteen_f_filing_data sec_entity[:filings][:recent]
  true
end

Instance Attribute Details

#business_state_or_countryObject (readonly)

Returns the value of attribute business_state_or_country.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def business_state_or_country
  @business_state_or_country
end

#cikObject (readonly)

Returns the value of attribute cik.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def cik
  @cik
end

#exchangesObject (readonly)

Returns the value of attribute exchanges.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def exchanges
  @exchanges
end

#filingsObject (readonly)

Returns the value of attribute filings.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def filings
  @filings
end

#fiscal_year_endObject (readonly)

Returns the value of attribute fiscal_year_end.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def fiscal_year_end
  @fiscal_year_end
end

#most_recent_positionsObject (readonly)

Returns the value of attribute most_recent_positions.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def most_recent_positions
  @most_recent_positions
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def name
  @name
end

#sicObject (readonly)

Returns the value of attribute sic.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def sic
  @sic
end

#sic_descriptionObject (readonly)

Returns the value of attribute sic_description.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def sic_description
  @sic_description
end

#tickersObject (readonly)

Returns the value of attribute tickers.



7
8
9
# File 'lib/thirteen_f/entity.rb', line 7

def tickers
  @tickers
end

Class Method Details

.from_cik(cik) ⇒ Object



15
16
17
18
19
20
# File 'lib/thirteen_f/entity.rb', line 15

def self.from_cik(cik)
  ten_digit_cik = cik
  ten_digit_cik.prepend('0') until ten_digit_cik.length >= 10
  entity_url = "https://data.sec.gov/submissions/CIK#{ten_digit_cik}.json"
  new SecRequest.get entity_url
end

Instance Method Details

#get_most_recent_positionsObject



40
41
42
43
44
# File 'lib/thirteen_f/entity.rb', line 40

def get_most_recent_positions
  most_recent_filing.get_positions
  @most_recent_positions =  most_recent_filing.positions
  true
end

#human_fiscal_year_endObject



36
37
38
# File 'lib/thirteen_f/entity.rb', line 36

def human_fiscal_year_end
  Time.strptime(@fiscal_year_end, '%m%d').strftime('%B %d')
end

#most_recent_filingObject



46
47
48
# File 'lib/thirteen_f/entity.rb', line 46

def most_recent_filing
  filings.select(&:period_of_report).max_by(&:period_of_report)
end