Class: OFX::OFX200::XMLParser
- Inherits:
-
Object
- Object
- OFX::OFX200::XMLParser
- Defined in:
- lib/ofx/2.0.0/xml_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #header ⇒ Object
-
#initialize(body) ⇒ XMLParser
constructor
A new instance of XMLParser.
- #to_document ⇒ Object
- #to_ofx_hash ⇒ Object
Constructor Details
#initialize(body) ⇒ XMLParser
Returns a new instance of XMLParser.
10 11 12 |
# File 'lib/ofx/2.0.0/xml_parser.rb', line 10 def initialize(body) @body = body.to_s.lstrip end |
Class Method Details
.xml_ofx?(body) ⇒ Boolean
6 7 8 |
# File 'lib/ofx/2.0.0/xml_parser.rb', line 6 def self.xml_ofx?(body) body.to_s.lstrip =~ /\A(?:<\?xml\b[^?]*\?>\s*)?<\?OFX\b/i ? true : false end |
Instance Method Details
#header ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/ofx/2.0.0/xml_parser.rb', line 14 def header header = OFX::Header.new processing_instruction_attributes.each do |key, value| header[key] = value end header['DATA'] ||= 'OFXXML' header end |
#to_document ⇒ Object
23 24 25 26 27 |
# File 'lib/ofx/2.0.0/xml_parser.rb', line 23 def to_document document = OFX::Document.from_ofx_hash(to_ofx_hash) document.header = header document end |
#to_ofx_hash ⇒ Object
29 30 31 |
# File 'lib/ofx/2.0.0/xml_parser.rb', line 29 def to_ofx_hash { document.root.name => element_to_hash_value(document.root) } end |