Class: Apperol::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, body, options = {}) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
# File 'lib/apperol/response.rb', line 5

def initialize(status, body, options = {})
  @status = status.to_i
  @original_body = body
  @headers = options[:headers]
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



3
4
5
# File 'lib/apperol/response.rb', line 3

def headers
  @headers
end

#original_bodyObject

Returns the value of attribute original_body.



3
4
5
# File 'lib/apperol/response.rb', line 3

def original_body
  @original_body
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/apperol/response.rb', line 3

def status
  @status
end

Instance Method Details

#[](key) ⇒ Object



19
20
21
22
# File 'lib/apperol/response.rb', line 19

def [](key)
  puts @headers
  @headers[key.downcase].first
end

#bodyObject



11
12
13
# File 'lib/apperol/response.rb', line 11

def body
  @body ||= JSON.parse(original_body)
end

#header(key) ⇒ Object



15
16
17
# File 'lib/apperol/response.rb', line 15

def header(key)
  @headers[key.downcase].first
end