Class: GraylogAPI::Client::Response
- Inherits:
-
Object
- Object
- GraylogAPI::Client::Response
- Defined in:
- lib/graylogapi/client/response.rb
Overview
Response of a http request
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #fail? ⇒ Boolean
-
#initialize(http_response) ⇒ Object
constructor
Initialize object of response.
- #keys ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(http_response) ⇒ Object
Initialize object of response
13 14 15 16 |
# File 'lib/graylogapi/client/response.rb', line 13 def initialize(http_response) self.body = parse_body(http_response.body) self.code = http_response.code.to_i end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
7 8 9 |
# File 'lib/graylogapi/client/response.rb', line 7 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
7 8 9 |
# File 'lib/graylogapi/client/response.rb', line 7 def code @code end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/graylogapi/client/response.rb', line 18 def [](key) body[key] end |
#fail? ⇒ Boolean
30 31 32 |
# File 'lib/graylogapi/client/response.rb', line 30 def fail? (400..599).cover? code end |
#keys ⇒ Object
22 23 24 |
# File 'lib/graylogapi/client/response.rb', line 22 def keys body.keys end |
#success? ⇒ Boolean
26 27 28 |
# File 'lib/graylogapi/client/response.rb', line 26 def success? (200..299).cover? code end |