Class: Edgar::Attachment

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

Overview

Represents a single file attachment within an SEC filing.

Constant Summary collapse

EXHIBIT_DESCRIPTIONS =
{
  "10-K" => "Annual Report",
  "10-Q" => "Quarterly Report",
  "8-K" => "Current Report",
  "EX-10" => "Material Contract",
  "EX-21" => "Subsidiaries",
  "EX-23" => "Consent of Expert",
  "EX-31" => "Certification",
  "EX-32" => "Certification"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sequence_number:, description: nil, document: nil, ixbrl: false, path: nil, document_type: nil, size: nil, sgml_document: nil, purpose: nil, url: nil) ⇒ Attachment

Returns a new instance of Attachment.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/edgar/attachment.rb', line 20

def initialize(sequence_number:, description: nil, document: nil, ixbrl: false,
               path: nil, document_type: nil, size: nil, sgml_document: nil,
               purpose: nil, url: nil)
  @sequence_number = sequence_number
  @description = description
  @document = document
  @ixbrl = ixbrl
  @path = path
  @document_type = document_type
  @size = size
  @sgml_document = sgml_document
  @purpose = purpose
  @url = url
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def description
  @description
end

#documentObject (readonly)

Returns the value of attribute document.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def document
  @document
end

#document_typeObject (readonly)

Returns the value of attribute document_type.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def document_type
  @document_type
end

#ixbrlObject (readonly)

Returns the value of attribute ixbrl.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def ixbrl
  @ixbrl
end

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def path
  @path
end

#purposeObject (readonly)

Returns the value of attribute purpose.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def purpose
  @purpose
end

#sequence_numberObject (readonly)

Returns the value of attribute sequence_number.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def sequence_number
  @sequence_number
end

#sgml_documentObject (readonly)

Returns the value of attribute sgml_document.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def sgml_document
  @sgml_document
end

#sizeObject (readonly)

Returns the value of attribute size.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def size
  @size
end

#urlObject (readonly)

Returns the value of attribute url.



17
18
19
# File 'lib/edgar/attachment.rb', line 17

def url
  @url
end

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/edgar/attachment.rb', line 57

def binary?
  !text? && !xml? && !html?
end

#display_descriptionObject



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

def display_description
  EXHIBIT_DESCRIPTIONS[@document_type] || @description
end

#empty?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/edgar/attachment.rb', line 61

def empty?
  @size.nil? || @size.to_i.zero?
end

#extensionObject



39
40
41
42
43
# File 'lib/edgar/attachment.rb', line 39

def extension
  return "" unless @document

  File.extname(@document).downcase
end

#html?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/edgar/attachment.rb', line 53

def html?
  [".htm", ".html"].include?(extension)
end

#text?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/edgar/attachment.rb', line 45

def text?
  extension == ".txt" || document_type&.include?("TEXT")
end

#to_sObject



65
66
67
# File 'lib/edgar/attachment.rb', line 65

def to_s
  "#<Attachment seq=#{@sequence_number} type=#{@document_type} desc='#{@description}'>"
end

#xml?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/edgar/attachment.rb', line 49

def xml?
  [".xml", ".xsl"].include?(extension)
end