Class: OFX::Handler
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- OFX::Handler
- Defined in:
- lib/ofx/handler.rb
Constant Summary collapse
- TRANSACTION_ATTRS =
[:TRNTYPE, :DTPOSTED, :TRNAMT, :FITID, :NAME]
- ATTRS_MAP =
{ TRNTYPE: :as_s, DTPOSTED: :as_time, TRNAMT: :as_f, FITID: :as_s, NAME: :as_s }
Instance Method Summary collapse
- #end_element(name) ⇒ Object
-
#initialize(parser) ⇒ Handler
constructor
A new instance of Handler.
- #start_element(name) ⇒ Object
- #value(value) ⇒ Object
Constructor Details
#initialize(parser) ⇒ Handler
Returns a new instance of Handler.
8 9 10 |
# File 'lib/ofx/handler.rb', line 8 def initialize(parser) @parser = parser end |
Instance Method Details
#end_element(name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ofx/handler.rb', line 22 def end_element(name) return unless name == :STMTTRN @parser.output[:transactions] = [] if @parser.output[:transactions].nil? @parser.output[:transactions].push( type: @transaction[:TRNTYPE], posted: @transaction[:DTPOSTED], amount: @transaction[:TRNAMT], fitid: @transaction[:FITID], name: @transaction[:NAME] ) end |
#start_element(name) ⇒ Object
12 13 14 15 |
# File 'lib/ofx/handler.rb', line 12 def start_element(name) @transaction = {} if name == :STMTTRN @current_node = name end |
#value(value) ⇒ Object
17 18 19 20 |
# File 'lib/ofx/handler.rb', line 17 def value(value) return unless TRANSACTION_ATTRS.include?(@current_node) @transaction[@current_node] = value.send(ATTRS_MAP[@current_node]) end |