Class: RedfishClient::Response
- Inherits:
-
Object
- Object
- RedfishClient::Response
- Defined in:
- lib/redfish_client/response.rb
Overview
Response struct.
This struct is returned from the methods that interact with the remote API.
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.
Class Method Summary collapse
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(status, headers, body) ⇒ Response
constructor
A new instance of Response.
- #monitor ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(status, headers, body) ⇒ Response
14 15 16 17 18 |
# File 'lib/redfish_client/response.rb', line 14 def initialize(status, headers, body) @status = status @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
12 13 14 |
# File 'lib/redfish_client/response.rb', line 12 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
11 12 13 |
# File 'lib/redfish_client/response.rb', line 11 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/redfish_client/response.rb', line 10 def status @status end |
Class Method Details
.from_hash(data) ⇒ Object
39 40 41 |
# File 'lib/redfish_client/response.rb', line 39 def self.from_hash(data) new(*data.values_at("status", "headers", "body")) end |
Instance Method Details
#done? ⇒ Boolean
20 21 22 |
# File 'lib/redfish_client/response.rb', line 20 def done? status != 202 end |
#monitor ⇒ Object
24 25 26 27 28 29 |
# File 'lib/redfish_client/response.rb', line 24 def monitor return nil if done? uri = URI.parse(headers["location"]) [uri.path, uri.query].compact.join("?") end |
#to_h ⇒ Object
31 32 33 |
# File 'lib/redfish_client/response.rb', line 31 def to_h { "status" => status, "headers" => headers, "body" => body } end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/redfish_client/response.rb', line 35 def to_s "Response[status=#{status}, headers=#{headers}, body='#{body}']" end |