Class: SecEdgar::FilingParser
- Inherits:
-
Object
- Object
- SecEdgar::FilingParser
- Defined in:
- lib/sec_edgar/filing_parser.rb
Instance Attribute Summary collapse
-
#xsd_uri ⇒ Object
readonly
Returns the value of attribute xsd_uri.
Instance Method Summary collapse
- #content ⇒ Object
- #derivative_transactions ⇒ Object
- #doc ⇒ Object
- #footnotes ⇒ Object
-
#initialize(filing) ⇒ FilingParser
constructor
A new instance of FilingParser.
- #parse(&error_blk) ⇒ Object
- #transactions ⇒ Object
- #xml_filing ⇒ Object
Constructor Details
#initialize(filing) ⇒ FilingParser
Returns a new instance of FilingParser.
5 6 7 8 9 |
# File 'lib/sec_edgar/filing_parser.rb', line 5 def initialize(filing) @xsd_uri = 'lib/sec4/ownership4Document.xsd.xml' @filing = filing @content = filing.content end |
Instance Attribute Details
#xsd_uri ⇒ Object (readonly)
Returns the value of attribute xsd_uri.
3 4 5 |
# File 'lib/sec_edgar/filing_parser.rb', line 3 def xsd_uri @xsd_uri end |
Instance Method Details
#content ⇒ Object
11 12 13 14 15 16 |
# File 'lib/sec_edgar/filing_parser.rb', line 11 def content if @content.start_with?('-----BEGIN PRIVACY-ENHANCED MESSAGE-----') @content = strip_privacy_wrapper(@content) end @content end |
#derivative_transactions ⇒ Object
47 48 49 |
# File 'lib/sec_edgar/filing_parser.rb', line 47 def derivative_transactions doc.derivative_transactions ||= [] end |
#doc ⇒ Object
18 19 20 |
# File 'lib/sec_edgar/filing_parser.rb', line 18 def doc @doc ||= SecEdgar::OwnershipDocument.new end |
#footnotes ⇒ Object
39 40 41 |
# File 'lib/sec_edgar/filing_parser.rb', line 39 def footnotes doc.footnotes ||= [] end |
#parse(&error_blk) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sec_edgar/filing_parser.rb', line 22 def parse(&error_blk) if block_given? && !xml_valid? error_blk.call(xml_errors) puts "Error: returning NilObjectDocument #{ @filing.link }" return SecEdgar::NilOwnershipDocument.new end footnotes | transactions | derivative_transactions # eager init parse_doc(xml_doc) parse_issuer(xml_doc.xpath('//issuer')) parse_owner(xml_doc.xpath('//reportingOwner')) parse_non_derivative_table(xml_doc.xpath('//nonDerivativeTable')) parse_derivative_table(xml_doc.xpath('//derivativeTable')) parse_footnotes(xml_doc.xpath('//footnotes')) doc end |
#transactions ⇒ Object
43 44 45 |
# File 'lib/sec_edgar/filing_parser.rb', line 43 def transactions doc.transactions ||= [] end |
#xml_filing ⇒ Object
51 52 53 |
# File 'lib/sec_edgar/filing_parser.rb', line 51 def xml_filing Nokogiri::XML(xml_doc.to_xml) end |