Class: Motion::HTTP::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_code, headers, body_string, body_object = nil) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
# File 'lib/common/http/response.rb', line 6

def initialize(status_code, headers, body_string, body_object = nil)
  @status_code = status_code
  @headers = headers
  @body = body_string
  @object = body_object
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



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

def headers
  @headers
end

#objectObject (readonly)

Returns the value of attribute object.



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

def object
  @object
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

Instance Method Details

#inspectObject



18
19
20
# File 'lib/common/http/response.rb', line 18

def inspect
  "<Motion::HTTP::Response status_code:#{status_code} headers:<#{headers.class}> body:<#{body.class}>>"
end

#success?Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/common/http/response.rb', line 13

def success?
  return false unless status_code
  status_code >= 200 && status_code < 300
end