Class: OFX::Parser::OFX102
- Inherits:
-
Object
- Object
- OFX::Parser::OFX102
- Defined in:
- lib/ofx_br/parser/ofx102.rb
Constant Summary collapse
- VERSION =
'1.0.2'- ACCOUNT_TYPES =
{ 'CHECKING' => :checking, 'SAVINGS' => :savings, 'CREDITLINE' => :creditline, 'MONEYMRKT' => :moneymrkt }
- TRANSACTION_TYPES =
%w[ ATM CASH CHECK CREDIT DEBIT DEP DIRECTDEBIT DIRECTDEP DIV FEE INT OTHER PAYMENT POS REPEATPMT SRVCHG XFER ].each_with_object({}) { |tran_type, hash| hash[tran_type] = tran_type.downcase.to_sym; }
- SEVERITY =
{ 'INFO' => :info, 'WARN' => :warn, 'ERROR' => :error }
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#date_end ⇒ Object
readonly
Returns the value of attribute date_end.
-
#date_start ⇒ Object
readonly
Returns the value of attribute date_start.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#html ⇒ Object
readonly
Returns the value of attribute html.
Class Method Summary collapse
Instance Method Summary collapse
-
#account ⇒ Object
DEPRECATED: kept for legacy support.
- #accounts ⇒ Object
-
#initialize(options = {}) ⇒ OFX102
constructor
A new instance of OFX102.
- #sign_on ⇒ Object
- #statements ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ OFX102
Returns a new instance of OFX102.
26 27 28 29 30 31 32 33 |
# File 'lib/ofx_br/parser/ofx102.rb', line 26 def initialize( = {}) @headers = [:headers] @body = [:body] @html = Nokogiri::HTML.parse(body) @date_start ||= build_date(@html.search('banktranlist > dtstart').inner_text) @date_end ||= build_date(@html.search('banktranlist > dtend').inner_text) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
24 25 26 |
# File 'lib/ofx_br/parser/ofx102.rb', line 24 def body @body end |
#date_end ⇒ Object (readonly)
Returns the value of attribute date_end.
24 25 26 |
# File 'lib/ofx_br/parser/ofx102.rb', line 24 def date_end @date_end end |
#date_start ⇒ Object (readonly)
Returns the value of attribute date_start.
24 25 26 |
# File 'lib/ofx_br/parser/ofx102.rb', line 24 def date_start @date_start end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
24 25 26 |
# File 'lib/ofx_br/parser/ofx102.rb', line 24 def headers @headers end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
24 25 26 |
# File 'lib/ofx_br/parser/ofx102.rb', line 24 def html @html end |
Class Method Details
.parse_headers(header_text) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ofx_br/parser/ofx102.rb', line 52 def self.parse_headers(header_text) # Change single CR's to LF's to avoid issues with some banks header_text.gsub!(/\r(?!\n)/, "\n") # Parse headers. When value is NONE, convert it to nil. headers = header_text.to_enum(:each_line).each_with_object({}) do |line, memo| _, key, value = *line.match(/^(.*?):(.*?)\s*(\r?\n)*$/) unless key.nil? memo[key] = value == 'NONE' ? nil : value end end return headers unless headers.empty? end |
Instance Method Details
#account ⇒ Object
DEPRECATED: kept for legacy support
44 45 46 |
# File 'lib/ofx_br/parser/ofx102.rb', line 44 def account @account ||= build_account(html.search('stmttrnrs, ccstmttrnrs').first) end |
#accounts ⇒ Object
39 40 41 |
# File 'lib/ofx_br/parser/ofx102.rb', line 39 def accounts @accounts ||= html.search('stmttrnrs, ccstmttrnrs').collect { |node| build_account(node) } end |
#sign_on ⇒ Object
48 49 50 |
# File 'lib/ofx_br/parser/ofx102.rb', line 48 def sign_on @sign_on ||= build_sign_on end |
#statements ⇒ Object
35 36 37 |
# File 'lib/ofx_br/parser/ofx102.rb', line 35 def statements @statements ||= html.search('stmttrnrs, ccstmttrnrs').collect { |node| build_statement(node) } end |