Class: Apnotic::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/apnotic/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Response

Returns a new instance of Response.



8
9
10
11
# File 'lib/apnotic/response.rb', line 8

def initialize(options={})
  @headers = options[:headers]
  @body    = options[:body]
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/apnotic/response.rb', line 6

def headers
  @headers
end

Instance Method Details

#bodyObject



21
22
23
# File 'lib/apnotic/response.rb', line 21

def body
  JSON.parse(@body) rescue @body
end

#ok?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/apnotic/response.rb', line 17

def ok?
  status == '200'
end

#statusObject



13
14
15
# File 'lib/apnotic/response.rb', line 13

def status
  @headers[':status'] if @headers
end