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.



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

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



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

def body
  @body
end

#codeObject

The HTTP status code of the response.



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

def code
  @code
end

#rawObject

The response body.



10
11
12
# File 'lib/ruby-notify-my-android/response.rb', line 10

def raw
  @raw
end

#responseObject

A hash of the cooked XML



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

def response
  @response
end

Instance Method Details

#succeeded?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ruby-notify-my-android/response.rb', line 28

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