Class: OFX::Parser::Base
- Inherits:
-
Object
- Object
- OFX::Parser::Base
- Defined in:
- lib/ofx/parser.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(resource) ⇒ Base
constructor
A new instance of Base.
- #open_resource(resource) ⇒ Object
Constructor Details
#initialize(resource) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ofx/parser.rb', line 9 def initialize(resource) @content = open_resource(resource).read @headers, @body = prepare(content) case @headers["VERSION"] when "102" then @parser = OFX::Parser::OFX102.new(:headers => headers, :body => body) else raise OFX::UnsupportedVersionError end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/ofx/parser.rb', line 5 def body @body end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/ofx/parser.rb', line 6 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
4 5 6 |
# File 'lib/ofx/parser.rb', line 4 def headers @headers end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
7 8 9 |
# File 'lib/ofx/parser.rb', line 7 def parser @parser end |
Instance Method Details
#open_resource(resource) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ofx/parser.rb', line 21 def open_resource(resource) if resource.respond_to?(:read) return resource else begin return open(resource) rescue return StringIO.new(resource) end end end |