class OFX::Handler
Constants
- ATTRS_MAP
- BALANCE_ATTRS
- TRANSACTION_ATTRS
Public Class Methods
new(parser)
click to toggle source
# File lib/ofx/handler.rb, line 9 def initialize(parser) @parser = parser end
Public Instance Methods
end_element(name)
click to toggle source
# File lib/ofx/handler.rb, line 30 def end_element(name) case name when :STMTTRN @parser.output[:transactions] = [] unless @parser.output[:transactions] @parser.output[:transactions].push(transaction) when :LEDGERBAL @parser.output[:balance] = @balance[:BALAMT] when :AVAILBAL @parser.output[:pending] = @balance[:BALAMT] - @parser.output[:balance] end end
start_element(name)
click to toggle source
# File lib/ofx/handler.rb, line 13 def start_element(name) case name when :STMTTRN then @transaction = {} when :LEDGERBAL || :AVAILBAL then @balance = {} end @current = name end
value(value)
click to toggle source
# File lib/ofx/handler.rb, line 21 def value(value) case when TRANSACTION_ATTRS.include?(@current) @transaction[@current] = value.send(ATTRS_MAP[@current]) when BALANCE_ATTRS.include?(@current) @balance[@current] = value.send(ATTRS_MAP[@current]) end end
Protected Instance Methods
transaction()
click to toggle source
# File lib/ofx/handler.rb, line 44 def transaction { type: @transaction[:TRNTYPE], posted: @transaction[:DTPOSTED], amount: @transaction[:TRNAMT], fitid: @transaction[:FITID], name: @transaction[:NAME] } end