Class: OFX::Parser::OFX211

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

Constant Summary collapse

VERSION =
"2.1.1"

Constants inherited from OFX102

OFX::Parser::OFX102::ACCOUNT_TYPES, OFX::Parser::OFX102::SEVERITY, OFX::Parser::OFX102::TRANSACTION_TYPES

Instance Attribute Summary

Attributes inherited from OFX102

#body, #headers, #html

Class Method Summary collapse

Methods inherited from OFX102

#account, #accounts, #initialize, #sign_on, #statements

Constructor Details

This class inherits a constructor from OFX::Parser::OFX102

Class Method Details

.extract_headers(text) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/ofx/parser/ofx211.rb', line 23

def self.extract_headers(text)
  headers = {}
  text.split(/\s+/).each do |attr_text|
    match = /(.+)="(.+)"/.match(attr_text)
    next unless match
    k, v = match[1], match[2]
    headers[k] = v
  end
  headers
end

.parse_headers(header_text) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ofx/parser/ofx211.rb', line 6

def self.parse_headers(header_text)
  doc = Nokogiri::XML(header_text)

  # Nokogiri can't search for processing instructions, so we
  # need to do this manually.
  doc.children.each do |e|
    if e.type == Nokogiri::XML::Node::PI_NODE && e.name == "OFX"
      # Getting the attributes from the element doesn't seem to
      # work either.
      return extract_headers(e.text)
    end
  end

  nil
end

.strip_quotes(s) ⇒ Object



34
35
36
37
# File 'lib/ofx/parser/ofx211.rb', line 34

def self.strip_quotes(s)
  return unless s
  s.sub(/^"(.*)"$/, '\1')
end