Class: Cuenote::Api::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/cuenote/api/response.rb

Instance Method Summary collapse

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

#attributesObject



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

#docObject



27
28
29
# File 'lib/cuenote/api/response.rb', line 27

def doc
  @doc ||= REXML::Document.new @response.body
end

#paramsObject



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

#resultObject



23
24
25
# File 'lib/cuenote/api/response.rb', line 23

def result
  @result ||= doc.elements['forecast/result']
end