Class: NMA::Response
- Inherits:
-
Object
- Object
- NMA::Response
- Defined in:
- lib/ruby-notify-my-android/response.rb
Overview
A wrapper around the API response.
Instance Attribute Summary collapse
-
#body ⇒ Object
A hash of the returned XML response.
-
#code ⇒ Object
The HTTP status code of the response.
-
#raw ⇒ Object
The response body.
-
#response ⇒ Object
A hash of the cooked XML.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #succeeded? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
26 27 28 29 30 31 |
# File 'lib/ruby-notify-my-android/response.rb', line 26 def initialize(response) self.raw = response.body self.code = response.code self.body = XmlSimple.xml_in(response.body) self.response = self.body[self.body.keys.first].first end |
Instance Attribute Details
#body ⇒ Object
A hash of the returned XML response
21 22 23 |
# File 'lib/ruby-notify-my-android/response.rb', line 21 def body @body end |
#code ⇒ Object
The HTTP status code of the response.
18 19 20 |
# File 'lib/ruby-notify-my-android/response.rb', line 18 def code @code end |
#raw ⇒ Object
The response body.
15 16 17 |
# File 'lib/ruby-notify-my-android/response.rb', line 15 def raw @raw end |
#response ⇒ Object
A hash of the cooked XML
24 25 26 |
# File 'lib/ruby-notify-my-android/response.rb', line 24 def response @response end |
Instance Method Details
#succeeded? ⇒ Boolean
33 34 35 |
# File 'lib/ruby-notify-my-android/response.rb', line 33 def succeeded? self.response["code"] == "200" end |