Class: Cuenote::Api::Response
- Inherits:
-
Object
- Object
- Cuenote::Api::Response
- Defined in:
- lib/cuenote/api/response.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #doc ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #params ⇒ Object
- #result ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/cuenote/api/response.rb', line 5 def initialize(response) @response = response end |
Instance Method Details
#attributes ⇒ Object
9 10 11 12 13 14 |
# File 'lib/cuenote/api/response.rb', line 9 def attributes @attributes ||= result.attributes.inject({}) do |hash, attr| hash[attr[0].to_sym] = attr[1] hash end end |
#doc ⇒ Object
27 28 29 |
# File 'lib/cuenote/api/response.rb', line 27 def doc @doc ||= REXML::Document.new @response.body end |
#params ⇒ Object
16 17 18 19 20 21 |
# File 'lib/cuenote/api/response.rb', line 16 def params @params ||= result.elements.map.inject({}) do |hash, element| hash[element.name.to_sym] = element.text hash end end |
#result ⇒ Object
23 24 25 |
# File 'lib/cuenote/api/response.rb', line 23 def result @result ||= doc.elements['forecast/result'] end |