Class: Amazon::Awis::Response
- Inherits:
-
Object
- Object
- Amazon::Awis::Response
- Defined in:
- lib/awis-wrapper.rb
Overview
Response object returned after a REST call to Amazon service.
Instance Method Summary collapse
- #doc ⇒ Object
-
#error ⇒ Object
Return error code.
- #get(tag) ⇒ Object
- #get_all(tag) ⇒ Object
-
#initialize(xml) ⇒ Response
constructor
XML input is in string format.
-
#method_missing(methodId) ⇒ Object
returns inner html of any tag in awis response i.e resp.rank => 3.
-
#success? ⇒ Boolean
Return error message.
- #xpath(path) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methodId) ⇒ Object
returns inner html of any tag in awis response i.e resp.rank => 3
137 138 139 140 |
# File 'lib/awis-wrapper.rb', line 137 def method_missing(methodId) puts methodId @doc.send methodId end |
Instance Method Details
#doc ⇒ Object
110 111 112 |
# File 'lib/awis-wrapper.rb', line 110 def doc @doc end |
#error ⇒ Object
Return error code
127 128 129 |
# File 'lib/awis-wrapper.rb', line 127 def error @doc.at_xpath("//aws:StatusMessage").content end |
#get(tag) ⇒ Object
118 119 120 |
# File 'lib/awis-wrapper.rb', line 118 def get(tag) Element.new @doc.at_xpath("//aws:#{Amazon::Awis.camel_case tag}", @namespace) end |
#get_all(tag) ⇒ Object
122 123 124 |
# File 'lib/awis-wrapper.rb', line 122 def get_all(tag) @doc.xpath("//aws:#{Amazon::Awis.camel_case tag}", @namespace).collect{|data|Element.new data} end |
#success? ⇒ Boolean
Return error message.
132 133 134 |
# File 'lib/awis-wrapper.rb', line 132 def success? (@doc.at_xpath "//aws:StatusCode").content == "Success" end |
#xpath(path) ⇒ Object
114 115 116 |
# File 'lib/awis-wrapper.rb', line 114 def xpath(path) @doc.xpath(path, @namesapce) end |