Class: Edgar::Attachments

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/edgar/attachments.rb

Overview

Enumerable collection of Attachment objects for a filing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachments = []) ⇒ Attachments

Returns a new instance of Attachments.



10
11
12
# File 'lib/edgar/attachments.rb', line 10

def initialize(attachments = [])
  @attachments = attachments
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



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

def attachments
  @attachments
end

Instance Method Details

#[](index) ⇒ Object



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

def [](index)
  @attachments[index]
end

#datafilesObject



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

def datafiles
  select(&:xml?)
end

#documentsObject



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

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

#each(&block) ⇒ Object



14
15
16
# File 'lib/edgar/attachments.rb', line 14

def each(&block)
  @attachments.each(&block)
end

#exhibitsObject



26
27
28
# File 'lib/edgar/attachments.rb', line 26

def exhibits
  select { |a| a.purpose&.downcase&.include?("exhibit") }
end

#lengthObject



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

def length
  @attachments.length
end

#primary_documentsObject



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

def primary_documents
  sorted = sort_by(&:sequence_number)
  sorted.select { |a| a.sequence_number == sorted.first&.sequence_number }
end

#primary_html_documentObject



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

def primary_html_document
  sorted = sort_by(&:sequence_number)
  sorted.find(&:html?)
end

#primary_xml_documentObject



48
49
50
# File 'lib/edgar/attachments.rb', line 48

def primary_xml_document
  find(&:xml?)
end

#reportsObject



30
31
32
# File 'lib/edgar/attachments.rb', line 30

def reports
  select { |a| a.purpose&.downcase&.include?("report") }
end

#statementsObject



34
35
36
# File 'lib/edgar/attachments.rb', line 34

def statements
  select { |a| a.purpose&.downcase&.include?("statement") }
end

#to_sObject



71
72
73
# File 'lib/edgar/attachments.rb', line 71

def to_s
  "#<Attachments count=#{@attachments.length}>"
end

#xbrl_documentObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/edgar/attachments.rb', line 52

def xbrl_document
  # Standard XBRL instance (EX-101.INS) or iXBRL-tagged document
  found = find { |a| a.document_type == "EX-101.INS" || a.ixbrl }
  return found if found

  # Fallback: look for _htm.xml extracted XBRL instance (common in modern
  # iXBRL filings where the instance is embedded in the HTML and an XML
  # copy is provided as a datafile)
  find { |a| a.document&.end_with?("_htm.xml") }
end