Class: Whoosh::HTTP::Response
- Inherits:
-
Object
- Object
- Whoosh::HTTP::Response
- Defined in:
- lib/whoosh/http/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status:, body:, headers: {}) ⇒ Response
constructor
A new instance of Response.
- #json ⇒ Object
- #ok? ⇒ Boolean
Constructor Details
#initialize(status:, body:, headers: {}) ⇒ Response
Returns a new instance of Response.
11 12 13 14 15 |
# File 'lib/whoosh/http/response.rb', line 11 def initialize(status:, body:, headers: {}) @status = status @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/whoosh/http/response.rb', line 9 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/whoosh/http/response.rb', line 9 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/whoosh/http/response.rb', line 9 def status @status end |
Instance Method Details
#json ⇒ Object
17 18 19 |
# File 'lib/whoosh/http/response.rb', line 17 def json @json ||= JSON.parse(@body) end |
#ok? ⇒ Boolean
21 22 23 |
# File 'lib/whoosh/http/response.rb', line 21 def ok? @status >= 200 && @status < 300 end |