Class: ThirteenF::Filing

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity, columnar_data) ⇒ Filing

Returns a new instance of Filing.



16
17
18
19
20
21
22
23
# File 'lib/thirteen_f/filing.rb', line 16

def initialize(entity, columnar_data)
  @entity = entity
  @index_url = assemble_index_url columnar_data[0]
  @report_date = Date.parse columnar_data[2]
  @time_accepted = DateTime.parse columnar_data[3]
  @form_type = columnar_data[5]
  true
end

Instance Attribute Details

#complete_text_file_urlObject (readonly)

Returns the value of attribute complete_text_file_url.



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

def complete_text_file_url
  @complete_text_file_url
end

#cover_page_html_urlObject (readonly)

Returns the value of attribute cover_page_html_url.



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

def cover_page_html_url
  @cover_page_html_url
end

#cover_page_xml_urlObject (readonly)

Returns the value of attribute cover_page_xml_url.



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

def cover_page_xml_url
  @cover_page_xml_url
end

#entityObject (readonly)

Returns the value of attribute entity.



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

def entity
  @entity
end

#form_typeObject (readonly)

Returns the value of attribute form_type.



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

def form_type
  @form_type
end

#index_urlObject (readonly)

Returns the value of attribute index_url.



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

def index_url
  @index_url
end

#positionsObject (readonly)

Returns the value of attribute positions.



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

def positions
  @positions
end

#report_dateObject (readonly) Also known as: period_of_report

Returns the value of attribute report_date.



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

def report_date
  @report_date
end

#table_html_urlObject (readonly)

Returns the value of attribute table_html_url.



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

def table_html_url
  @table_html_url
end

#table_xml_urlObject (readonly)

Returns the value of attribute table_xml_url.



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

def table_xml_url
  @table_xml_url
end

#time_acceptedObject (readonly)

Returns the value of attribute time_accepted.



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

def time_accepted
  @time_accepted
end

Instance Method Details

#assemble_index_url(accession_number) ⇒ Object



25
26
27
# File 'lib/thirteen_f/filing.rb', line 25

def assemble_index_url(accession_number)
  "#{BASE_URL}/Archives/edgar/data/#{entity.cik}/#{accession_number.delete('-')}/#{accession_number}-index.htm"
end

#get_positionsObject



29
30
31
32
33
# File 'lib/thirteen_f/filing.rb', line 29

def get_positions
  set_attributes_from_index_url unless table_xml_url
  @positions = Position.from_xml_filing self
  true
end

#set_attributes_from_index_urlObject



35
36
37
38
39
# File 'lib/thirteen_f/filing.rb', line 35

def set_attributes_from_index_url
  return unless index_url
  response = SecRequest.get index_url, response_type: :html
  assign_attributes(**set_attributes(response))
end