Class: Kameleoon::Network::Response

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

Overview

Response represents HTTP response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, code, body, request) ⇒ Response

Returns a new instance of Response.



14
15
16
17
18
19
# File 'lib/kameleoon/network/response.rb', line 14

def initialize(error, code, body, request)
  @error = error
  @code = code
  @body = body
  @request = request
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

#requestObject (readonly)

Returns the value of attribute request.



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

def request
  @request
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  @error.nil? && ((@code / 100 == 2) || (@code == 403))
end

#to_sObject



10
11
12
# File 'lib/kameleoon/network/response.rb', line 10

def to_s
  "HttpResponse{Code:'#{@code}',Reason:'#{@error}',Body:#{@body}}"
end