Class: AmazonRuby::Response
- Inherits:
-
Object
- Object
- AmazonRuby::Response
- Defined in:
- lib/amazon-ruby/response.rb
Instance Method Summary collapse
-
#find(attribute) ⇒ Object
Return array of values This is pretty generic.
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
-
#is_valid ⇒ Object
Was the response valid?.
-
#response_body ⇒ Object
Body of response.
-
#response_code ⇒ Object
Response code.
-
#xml ⇒ Object
The XML document.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
4 5 6 7 |
# File 'lib/amazon-ruby/response.rb', line 4 def initialize(response) @response_body = response.body @response_code = response.code.to_i end |
Instance Method Details
#find(attribute) ⇒ Object
Return array of values This is pretty generic. This should be a LOT more robust.
26 27 28 29 30 |
# File 'lib/amazon-ruby/response.rb', line 26 def find(attribute) result = Array.new xml.xpath("//xmlns:#{attribute}").map do |e| result << e.text end result end |
#is_valid ⇒ Object
Was the response valid?
20 21 22 |
# File 'lib/amazon-ruby/response.rb', line 20 def is_valid @response_code == 200 ? true : false; end |
#response_body ⇒ Object
Body of response
10 11 12 |
# File 'lib/amazon-ruby/response.rb', line 10 def response_body @response_body end |
#response_code ⇒ Object
Response code
15 16 17 |
# File 'lib/amazon-ruby/response.rb', line 15 def response_code @response_code end |
#xml ⇒ Object
The XML document.
33 34 35 |
# File 'lib/amazon-ruby/response.rb', line 33 def xml Nokogiri::XML(@response_body) end |