Class: Edgar::FilingHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/edgar/filing_header.rb

Overview

Parses the section of an SEC filing text.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sgml_text) ⇒ FilingHeader

Returns a new instance of FilingHeader.



8
9
10
11
12
13
# File 'lib/edgar/filing_header.rb', line 8

def initialize(sgml_text)
  @raw_text = ""
  @fields = {}

  parse_header(sgml_text.to_s)
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



6
7
8
# File 'lib/edgar/filing_header.rb', line 6

def fields
  @fields
end

#raw_textObject (readonly)

Returns the value of attribute raw_text.



6
7
8
# File 'lib/edgar/filing_header.rb', line 6

def raw_text
  @raw_text
end

Instance Method Details

#accession_numberObject



43
44
45
# File 'lib/edgar/filing_header.rb', line 43

def accession_number
  @fields["ACCESSION NUMBER"]&.first
end

#filer_cikObject



31
32
33
# File 'lib/edgar/filing_header.rb', line 31

def filer_cik
  filers.first["COMPANY DATA CENTRAL INDEX KEY"] || filers.first["CENTRAL INDEX KEY"] if filers.any?
end

#filer_companyObject



35
36
37
# File 'lib/edgar/filing_header.rb', line 35

def filer_company
  filers.first["COMPANY DATA COMPANY CONFORMED NAME"] || filers.first["COMPANY CONFORMED NAME"] if filers.any?
end

#filersObject



15
16
17
# File 'lib/edgar/filing_header.rb', line 15

def filers
  @fields["FILER"] || []
end

#form_typeObject



39
40
41
# File 'lib/edgar/filing_header.rb', line 39

def form_type
  @fields["FORM TYPE"]&.first || @fields["CONFORMED SUBMISSION TYPE"]&.first
end

#period_of_reportObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/edgar/filing_header.rb', line 19

def period_of_report
  raw = @fields["CONFORMED PERIOD OF REPORT"]&.first
  return nil unless raw

  # Format YYYYMMDD as YYYY-MM-DD (ISO 8601)
  if raw.match?(/\A\d{8}\z/)
    "#{raw[0..3]}-#{raw[4..5]}-#{raw[6..7]}"
  else
    raw
  end
end

#to_sObject



47
48
49
# File 'lib/edgar/filing_header.rb', line 47

def to_s
  "#<FilingHeader #{@fields.keys.length} keys>"
end