Class: OFX::Base::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/ofx_kit/base/document.rb

Overview

Wraps the parsed OFX file, providing access to headers and XML body nodes. Consumers use #bank_statement_nodes and #credit_card_statement_nodes to extract statement data for domain object construction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers:, body:) ⇒ Document

Returns a new instance of Document.



11
12
13
14
# File 'lib/ofx_kit/base/document.rb', line 11

def initialize(headers:, body:)
  @headers = headers
  @body    = body
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



9
10
11
# File 'lib/ofx_kit/base/document.rb', line 9

def headers
  @headers
end

Instance Method Details

#bank_statement_nodesNokogiri::XML::NodeSet

Returns all STMTRS (bank statement) nodes in the document.

Returns:

  • (Nokogiri::XML::NodeSet)

    all STMTRS (bank statement) nodes in the document



22
23
24
# File 'lib/ofx_kit/base/document.rb', line 22

def bank_statement_nodes
  @body.css('STMTRS')
end

#credit_card_statement_nodesNokogiri::XML::NodeSet

Returns all CCSTMTRS (credit card statement) nodes in the document.

Returns:

  • (Nokogiri::XML::NodeSet)

    all CCSTMTRS (credit card statement) nodes in the document



27
28
29
# File 'lib/ofx_kit/base/document.rb', line 27

def credit_card_statement_nodes
  @body.css('CCSTMTRS')
end

#versionString?

Returns OFX version declared in the file header.

Returns:

  • (String, nil)

    OFX version declared in the file header



17
18
19
# File 'lib/ofx_kit/base/document.rb', line 17

def version
  @headers['VERSION']
end