Class: Daengine::HTTP::Response
- Inherits:
-
Object
- Object
- Daengine::HTTP::Response
- Defined in:
- lib/daengine/http_client.rb
Instance Method Summary collapse
- #as_hash ⇒ Object
- #body ⇒ Object
- #client_error? ⇒ Boolean
- #failed? ⇒ Boolean
- #headers ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #redirection? ⇒ Boolean
- #server_error? ⇒ Boolean
- #status ⇒ Object (also: #code, #status_code)
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
54 55 56 |
# File 'lib/daengine/http_client.rb', line 54 def initialize(response) @resp = response end |
Instance Method Details
#as_hash ⇒ Object
70 71 72 |
# File 'lib/daengine/http_client.rb', line 70 def as_hash @resp.parsed_response end |
#body ⇒ Object
62 63 64 |
# File 'lib/daengine/http_client.rb', line 62 def body @resp.body end |
#client_error? ⇒ Boolean
89 90 91 |
# File 'lib/daengine/http_client.rb', line 89 def client_error? !!(status.to_s =~ /^4/) end |
#failed? ⇒ Boolean
81 82 83 |
# File 'lib/daengine/http_client.rb', line 81 def failed? !success? end |
#headers ⇒ Object
58 59 60 |
# File 'lib/daengine/http_client.rb', line 58 def headers @resp.headers end |
#redirection? ⇒ Boolean
93 94 95 |
# File 'lib/daengine/http_client.rb', line 93 def redirection? !!(status.to_s =~ /^3/) end |
#server_error? ⇒ Boolean
85 86 87 |
# File 'lib/daengine/http_client.rb', line 85 def server_error? !!(status.to_s =~ /^5/) end |
#status ⇒ Object Also known as: code, status_code
66 67 68 |
# File 'lib/daengine/http_client.rb', line 66 def status @resp.code end |
#success? ⇒ Boolean
77 78 79 |
# File 'lib/daengine/http_client.rb', line 77 def success? !!(status.to_s =~ /^2/) end |