Class: Edgar::Filing

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

Overview

A single SEC filing: form type, date, text, attachments, and XBRL data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cik:, company:, form:, filing_date:, accession_number:) ⇒ Filing

Returns a new instance of Filing.



8
9
10
11
12
13
14
15
16
# File 'lib/edgar/filing.rb', line 8

def initialize(cik:, company:, form:, filing_date:, accession_number:)
  @cik = cik.to_i
  @company = company
  @form = form
  @filing_date = filing_date.is_a?(Date) ? filing_date : Date.parse(filing_date.to_s)
  @accession_number = accession_number
  @sgml = nil
  @homepage_soup = nil
end

Instance Attribute Details

#accession_numberObject (readonly)

Returns the value of attribute accession_number.



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

def accession_number
  @accession_number
end

#cikObject (readonly)

Returns the value of attribute cik.



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

def cik
  @cik
end

#companyObject (readonly)

Returns the value of attribute company.



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

def company
  @company
end

#filing_dateObject (readonly)

Returns the value of attribute filing_date.



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

def filing_date
  @filing_date
end

#formObject (readonly)

Returns the value of attribute form.



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

def form
  @form
end

Instance Method Details

#accession_noObject



115
116
117
# File 'lib/edgar/filing.rb', line 115

def accession_no
  @accession_number
end

#all_ciksObject



18
19
20
# File 'lib/edgar/filing.rb', line 18

def all_ciks
  [@cik]
end

#attachmentsObject



79
80
81
# File 'lib/edgar/filing.rb', line 79

def attachments
  homepage.attachments
end

#base_dirObject



41
42
43
44
# File 'lib/edgar/filing.rb', line 41

def base_dir
  no_dashes = @accession_number.delete("-")
  "#{Config::SEC_ARCHIVE_URL}/data/#{@cik}/#{no_dashes}"
end

#exhibitsObject



83
84
85
# File 'lib/edgar/filing.rb', line 83

def exhibits
  attachments.exhibits
end

#filing_urlObject



26
27
28
29
30
31
# File 'lib/edgar/filing.rb', line 26

def filing_url
  primary = homepage.primary_html_document
  return primary.url if primary

  text_url
end

#headerObject



46
47
48
# File 'lib/edgar/filing.rb', line 46

def header
  @header ||= FilingHeader.new(sgml)
end

#homepageObject



58
59
60
# File 'lib/edgar/filing.rb', line 58

def homepage
  @homepage ||= fetch_homepage
end

#homepage_urlObject



33
34
35
# File 'lib/edgar/filing.rb', line 33

def homepage_url
  Config.filing_homepage_url(@cik, @accession_number)
end

#htmlObject



62
63
64
65
# File 'lib/edgar/filing.rb', line 62

def html
  doc = homepage.primary_html_document
  doc ? download_attachment(doc) : ""
end

#markdownObject



119
120
121
122
123
124
125
126
127
128
# File 'lib/edgar/filing.rb', line 119

def markdown
  text = sgml
  return "" if text.empty?

  text
    .gsub(/<[^>]+>/, "")
    .gsub(/&[a-zA-Z]+;/, " ")
    .gsub(/\n{3,}/, "\n\n")
    .strip
end

#multi_entity?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/edgar/filing.rb', line 22

def multi_entity?
  all_ciks.length > 1
end

#objObject



111
112
113
# File 'lib/edgar/filing.rb', line 111

def obj
  DataObjects.for(self)
end

#period_of_reportObject



50
51
52
# File 'lib/edgar/filing.rb', line 50

def period_of_report
  header.period_of_report
end

#reportsObject



87
88
89
# File 'lib/edgar/filing.rb', line 87

def reports
  attachments.reports
end

#section_markersObject



103
104
105
# File 'lib/edgar/filing.rb', line 103

def section_markers
  @section_markers ||= Edgar::FilingSections.extract_sections(sgml)
end

#sectionsObject



107
108
109
# File 'lib/edgar/filing.rb', line 107

def sections
  Edgar::FilingSections.find_sections(sgml, form_type: @form)
end

#sgmlObject



54
55
56
# File 'lib/edgar/filing.rb', line 54

def sgml
  @sgml ||= fetch_sgml
end

#statementsObject



91
92
93
# File 'lib/edgar/filing.rb', line 91

def statements
  attachments.statements
end

#textObject



72
73
74
75
76
77
# File 'lib/edgar/filing.rb', line 72

def text
  sgml_text = sgml_raw_text
  return sgml_text if sgml_text

  download_text_file
end

#text_urlObject



37
38
39
# File 'lib/edgar/filing.rb', line 37

def text_url
  Config.filing_text_url(@cik, @accession_number)
end

#to_sObject



130
131
132
# File 'lib/edgar/filing.rb', line 130

def to_s
  "#<Filing #{@form} #{@company} #{@filing_date} #{@accession_number}>"
end

#xbrlObject



95
96
97
98
99
100
101
# File 'lib/edgar/filing.rb', line 95

def xbrl
  doc = homepage.xbrl_document
  return nil unless doc

  content = download_attachment(doc)
  XBRL::XBRL.new(content)
end

#xmlObject



67
68
69
70
# File 'lib/edgar/filing.rb', line 67

def xml
  doc = homepage.primary_xml_document
  doc ? download_attachment(doc) : ""
end