Class: Edgar::FilingHomepage

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

Overview

Parses the SEC filing HTML index page listing document attachments.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, soup = nil) ⇒ FilingHomepage

Returns a new instance of FilingHomepage.



10
11
12
13
14
# File 'lib/edgar/filing_homepage.rb', line 10

def initialize(url, soup = nil)
  @url = url
  @soup = soup || fetch_soup
  @attachments = parse_attachments
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



8
9
10
# File 'lib/edgar/filing_homepage.rb', line 8

def attachments
  @attachments
end

#soupObject (readonly)

Returns the value of attribute soup.



8
9
10
# File 'lib/edgar/filing_homepage.rb', line 8

def soup
  @soup
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/edgar/filing_homepage.rb', line 8

def url
  @url
end

Class Method Details

.emptyObject



16
17
18
# File 'lib/edgar/filing_homepage.rb', line 16

def self.empty
  new("", Nokogiri::HTML(""))
end

Instance Method Details

#datafilesObject



24
25
26
# File 'lib/edgar/filing_homepage.rb', line 24

def datafiles
  @attachments.select(&:xml?)
end

#documentsObject



20
21
22
# File 'lib/edgar/filing_homepage.rb', line 20

def documents
  @attachments.select { |a| a.html? || a.text? }
end

#filersObject



50
51
52
53
54
# File 'lib/edgar/filing_homepage.rb', line 50

def filers
  @soup.css("div.filer, .companyInfo, .mailer").map do |el|
    { name: el.text.strip }
  end
end

#period_of_reportObject



44
45
46
47
48
# File 'lib/edgar/filing_homepage.rb', line 44

def period_of_report
  text = @soup.text
  match = text.match(/Period of Report\s*:\s*(\S+)/i)
  match ? match[1] : nil
end

#primary_documentsObject



28
29
30
# File 'lib/edgar/filing_homepage.rb', line 28

def primary_documents
  @attachments.primary_documents
end

#primary_html_documentObject



32
33
34
# File 'lib/edgar/filing_homepage.rb', line 32

def primary_html_document
  @attachments.primary_html_document
end

#primary_xml_documentObject



36
37
38
# File 'lib/edgar/filing_homepage.rb', line 36

def primary_xml_document
  @attachments.primary_xml_document
end

#to_sObject



56
57
58
# File 'lib/edgar/filing_homepage.rb', line 56

def to_s
  "#<FilingHomepage #{@url}>"
end

#xbrl_documentObject



40
41
42
# File 'lib/edgar/filing_homepage.rb', line 40

def xbrl_document
  @attachments.xbrl_document
end