Class: DruidClient::Api::Response
- Inherits:
-
Object
- Object
- DruidClient::Api::Response
- Defined in:
- lib/druid_client/api/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(status_code:, body:, headers: {}, duration: nil) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(status_code:, body:, headers: {}, duration: nil) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 |
# File 'lib/druid_client/api/response.rb', line 8 def initialize(status_code:, body:, headers: {}, duration: nil) @status_code = status_code @body = body @headers = headers @duration = duration end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/druid_client/api/response.rb', line 6 def body @body end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/druid_client/api/response.rb', line 6 def duration @duration end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/druid_client/api/response.rb', line 6 def headers @headers end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
6 7 8 |
# File 'lib/druid_client/api/response.rb', line 6 def status_code @status_code end |
Instance Method Details
#error? ⇒ Boolean
21 22 23 |
# File 'lib/druid_client/api/response.rb', line 21 def error? !success? end |
#success? ⇒ Boolean
15 16 17 18 19 |
# File 'lib/druid_client/api/response.rb', line 15 def success? return false unless status_code (200..299).include?(status_code) end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/druid_client/api/response.rb', line 25 def to_s "#<Response status_code=#{status_code} duration=#{duration}s>" end |