Class: NMA::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-notify-my-android/response.rb

Overview

A wrapper around the API response.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject

A hash of the returned XML response



21
22
23
# File 'lib/ruby-notify-my-android/response.rb', line 21

def body
  @body
end

#codeObject

The HTTP status code of the response.



18
19
20
# File 'lib/ruby-notify-my-android/response.rb', line 18

def code
  @code
end

#rawObject

The response body.



15
16
17
# File 'lib/ruby-notify-my-android/response.rb', line 15

def raw
  @raw
end

#responseObject

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

Returns:

  • (Boolean)


33
34
35
# File 'lib/ruby-notify-my-android/response.rb', line 33

def succeeded?
  self.response["code"] == "200"
end