Class: Apis::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, headers, body) ⇒ Response

Returns a new instance of Response.



4
5
6
# File 'lib/apis/response.rb', line 4

def initialize(status, headers, body)
  @status, @headers, @body = status, headers, body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#headersObject

Returns the value of attribute headers.



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

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#[](key) ⇒ Object



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

def [](key)
  respond_to?(key) ? send(key) : nil
end

#[]=(key, value) ⇒ Object



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

def []=(key, value)
  send("#{key}=", value) if respond_to?("#{key}=")
end

#to_aObject Also known as: to_ary



12
13
14
# File 'lib/apis/response.rb', line 12

def to_a
  [status, headers, body]
end

#to_envObject



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

def to_env
  {:status => status, :headers => headers, :body => body}
end