Class: OFX::Parser::OFX102

Inherits:
Object
  • Object
show all
Defined in:
lib/ofx/parser/ofx102.rb

Direct Known Subclasses

OFX211

Constant Summary collapse

VERSION =
"1.0.2"
ACCOUNT_TYPES =
{
  "CHECKING" => :checking
}
TRANSACTION_TYPES =
{
  "CREDIT" => :credit,
  "DEBIT" => :debit,
  "OTHER" => :other,
  "DEP" => :dep,
  "XFER" => :xfer,
  "CASH" => :cash,
  "CHECK" => :check
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ OFX102

Returns a new instance of OFX102.



26
27
28
29
30
# File 'lib/ofx/parser/ofx102.rb', line 26

def initialize(options = {})
  @headers = options[:headers]
  @body = options[:body]
  @html = Nokogiri::HTML.parse(body)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



23
24
25
# File 'lib/ofx/parser/ofx102.rb', line 23

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



22
23
24
# File 'lib/ofx/parser/ofx102.rb', line 22

def headers
  @headers
end

#htmlObject (readonly)

Returns the value of attribute html.



24
25
26
# File 'lib/ofx/parser/ofx102.rb', line 24

def html
  @html
end

Class Method Details

.parse_headers(header_text) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ofx/parser/ofx102.rb', line 36

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

#accountObject



32
33
34
# File 'lib/ofx/parser/ofx102.rb', line 32

def 
  @account ||= 
end