Class: OFX::Parser::OFX102
- Inherits:
-
Object
- Object
- OFX::Parser::OFX102
- Defined in:
- lib/ofx/parser/ofx102.rb
Direct Known Subclasses
Constant Summary collapse
- VERSION =
"1.0.2"
- ACCOUNT_TYPES =
{ "CHECKING" => :checking }
- TRANSACTION_TYPES =
[ 'ATM', 'CASH', 'CHECK', 'CREDIT', 'DEBIT', 'DEP', 'DIRECTDEBIT', 'DIRECTDEP', 'DIV', 'FEE', 'INT', 'OTHER', 'PAYMENT', 'POS', 'REPEATPMT', 'SRVCHG', 'XFER' ].inject({}) { |hash, tran_type| hash[tran_type] = tran_type.downcase.to_sym; hash }
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#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
-
#initialize(options = {}) ⇒ OFX102
constructor
A new instance of OFX102.
Constructor Details
#initialize(options = {}) ⇒ OFX102
Returns a new instance of OFX102.
20 21 22 23 24 |
# File 'lib/ofx/parser/ofx102.rb', line 20 def initialize( = {}) @headers = [:headers] @body = [:body] @html = Nokogiri::HTML.parse(body) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
17 18 19 |
# File 'lib/ofx/parser/ofx102.rb', line 17 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
16 17 18 |
# File 'lib/ofx/parser/ofx102.rb', line 16 def headers @headers end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
18 19 20 |
# File 'lib/ofx/parser/ofx102.rb', line 18 def html @html end |
Class Method Details
.parse_headers(header_text) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ofx/parser/ofx102.rb', line 30 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).inject({}) do |memo, line| _, key, value = *line.match(/^(.*?):(.*?)\s*(\r?\n)*$/) unless key.nil? memo[key] = value == "NONE" ? nil : value end memo end return headers unless headers.empty? end |
Instance Method Details
#account ⇒ Object
26 27 28 |
# File 'lib/ofx/parser/ofx102.rb', line 26 def account @account ||= build_account end |