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
139 140 141 142 |
# File 'lib/awis-wrapper.rb', line 139 def method_missing(methodId) puts methodId @doc.send methodId end |
Instance Method Details
#doc ⇒ Object
112 113 114 |
# File 'lib/awis-wrapper.rb', line 112 def doc @doc end |
#error ⇒ Object
Return error code
129 130 131 |
# File 'lib/awis-wrapper.rb', line 129 def error @doc.at_xpath("//aws:StatusMessage").content end |
#get(tag) ⇒ Object
120 121 122 |
# File 'lib/awis-wrapper.rb', line 120 def get(tag) Element.new @doc.at_xpath("//aws:#{Amazon::Awis.camel_case tag}", @namespace) end |
#get_all(tag) ⇒ Object
124 125 126 |
# File 'lib/awis-wrapper.rb', line 124 def get_all(tag) @doc.xpath("//aws:#{Amazon::Awis.camel_case tag}", @namespace).collect{|data|Element.new data} end |
#success? ⇒ Boolean
Return error message.
134 135 136 |
# File 'lib/awis-wrapper.rb', line 134 def success? (@doc.at_xpath "//aws:StatusCode").content == "Success" end |
#xpath(path) ⇒ Object
116 117 118 |
# File 'lib/awis-wrapper.rb', line 116 def xpath(path) @doc.xpath(path, @namesapce) end |