Class: EzClient::Response
- Inherits:
-
Object
- Object
- EzClient::Response
- Defined in:
- lib/ezclient/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#http_request ⇒ Object
Returns the value of attribute http_request.
-
#http_response ⇒ Object
Returns the value of attribute http_response.
Instance Method Summary collapse
- #client_error? ⇒ Boolean
- #code ⇒ Object (also: #status)
- #cookies ⇒ Object
- #error? ⇒ Boolean
- #headers ⇒ Object
-
#initialize(http_response, http_request) ⇒ Response
constructor
A new instance of Response.
- #ok? ⇒ Boolean
- #redirect? ⇒ Boolean
- #server_error? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(http_response, http_request) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/ezclient/response.rb', line 6 def initialize(http_response, http_request) self.http_response = http_response self.http_request = http_request self.body = http_response.body.to_s # Make sure we read the body for persistent connection end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/ezclient/response.rb', line 4 def body @body end |
#http_request ⇒ Object
Returns the value of attribute http_request.
4 5 6 |
# File 'lib/ezclient/response.rb', line 4 def http_request @http_request end |
#http_response ⇒ Object
Returns the value of attribute http_response.
4 5 6 |
# File 'lib/ezclient/response.rb', line 4 def http_response @http_response end |
Instance Method Details
#client_error? ⇒ Boolean
33 34 35 |
# File 'lib/ezclient/response.rb', line 33 def client_error? code.between?(400, 499) end |
#code ⇒ Object Also known as: status
16 17 18 |
# File 'lib/ezclient/response.rb', line 16 def code http_response.code end |
#cookies ⇒ Object
21 22 23 |
# File 'lib/ezclient/response.rb', line 21 def http_response. end |
#error? ⇒ Boolean
41 42 43 |
# File 'lib/ezclient/response.rb', line 41 def error? client_error? || server_error? end |
#headers ⇒ Object
12 13 14 |
# File 'lib/ezclient/response.rb', line 12 def headers http_response.headers end |
#ok? ⇒ Boolean
25 26 27 |
# File 'lib/ezclient/response.rb', line 25 def ok? code.between?(200, 299) end |
#redirect? ⇒ Boolean
29 30 31 |
# File 'lib/ezclient/response.rb', line 29 def redirect? code.between?(300, 399) end |
#server_error? ⇒ Boolean
37 38 39 |
# File 'lib/ezclient/response.rb', line 37 def server_error? code.between?(500, 599) end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/ezclient/response.rb', line 45 def to_s inspect end |