Class: Kameleoon::Network::Response
- Inherits:
-
Object
- Object
- Kameleoon::Network::Response
- Defined in:
- lib/kameleoon/network/response.rb
Overview
Response represents HTTP response.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(error, code, body, request) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #to_s ⇒ Object
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/kameleoon/network/response.rb', line 8 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/kameleoon/network/response.rb', line 8 def code @code end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
8 9 10 |
# File 'lib/kameleoon/network/response.rb', line 8 def error @error end |
#request ⇒ Object (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
21 22 23 |
# File 'lib/kameleoon/network/response.rb', line 21 def success? @error.nil? && ((@code / 100 == 2) || (@code == 403)) end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/kameleoon/network/response.rb', line 10 def to_s "HttpResponse{Code:'#{@code}',Reason:'#{@error}',Body:#{@body}}" end |