Class: OFXReader::Parser::OFX102

Inherits:
Struct
  • Object
show all
Defined in:
lib/ofx_reader/parser/ofx_102.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ofx_bodyObject

Returns the value of attribute ofx_body

Returns:

  • (Object)

    the current value of ofx_body



3
4
5
# File 'lib/ofx_reader/parser/ofx_102.rb', line 3

def ofx_body
  @ofx_body
end

#strictObject

Returns the value of attribute strict

Returns:

  • (Object)

    the current value of strict



3
4
5
# File 'lib/ofx_reader/parser/ofx_102.rb', line 3

def strict
  @strict
end

Instance Method Details

#accountObject



9
10
11
12
13
# File 'lib/ofx_reader/parser/ofx_102.rb', line 9

def 
  (
    build(ofx_body.search('BANKACCTFROM'))
  )
end

#build_account(hash) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ofx_reader/parser/ofx_102.rb', line 15

def (hash)
   = [
    hash.dig(:branchid),
    hash.dig(:acctid)
  ].compact.join(' - ')

  hash[:bankid] = hash[:bankid].
    reverse[0..2].
    reverse.
    rjust(3, '0') if hash[:bankid].present?

  hash.merge!({
    full_account: 
  }) if hash.dig(:acctid).present?

  hash
end

#parseObject



4
5
6
7
# File 'lib/ofx_reader/parser/ofx_102.rb', line 4

def parse
  raise OFXReader::OFXWithoutBankAccountError if empty_account?
  [, transactions]
end

#transactionsObject



33
34
35
36
37
# File 'lib/ofx_reader/parser/ofx_102.rb', line 33

def transactions
  ofx_body.search('BANKTRANLIST STMTTRN').map do |node|
    build(node)
  end
end