Class: AmazonRuby::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon-ruby/response.rb

Instance Method Summary collapse

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_validObject

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_bodyObject

Body of response



10
11
12
# File 'lib/amazon-ruby/response.rb', line 10

def response_body
	@response_body
end

#response_codeObject

Response code



15
16
17
# File 'lib/amazon-ruby/response.rb', line 15

def response_code
	@response_code
end

#xmlObject

The XML document.



33
34
35
# File 'lib/amazon-ruby/response.rb', line 33

def xml
	Nokogiri::XML(@response_body)
end