Class: Kitchen::Driver::Azure::Http::Response
- Inherits:
-
Struct
- Object
- Struct
- Kitchen::Driver::Azure::Http::Response
- Defined in:
- lib/kitchen/driver/azure/http.rb
Overview
One HTTP response.
Instance Attribute Summary collapse
- #body ⇒ String readonly
- #status ⇒ Integer readonly
Instance Method Summary collapse
-
#json ⇒ Hash, ...
The response body parsed as JSON.
-
#success? ⇒ Boolean
Whether the status is in the 2xx range.
Instance Attribute Details
#body ⇒ String (readonly)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kitchen/driver/azure/http.rb', line 51 Response = Struct.new(:status, :body) do # @return [Boolean] whether the status is in the 2xx range. def success? status.between?(200, 299) end # The response body parsed as JSON. # # @return [Hash, Array, nil] nil when the body is empty or not JSON. def json return nil if body.nil? || body.empty? JSON.parse(body) rescue JSON::ParserError nil end end |
#status ⇒ Integer (readonly)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kitchen/driver/azure/http.rb', line 51 Response = Struct.new(:status, :body) do # @return [Boolean] whether the status is in the 2xx range. def success? status.between?(200, 299) end # The response body parsed as JSON. # # @return [Hash, Array, nil] nil when the body is empty or not JSON. def json return nil if body.nil? || body.empty? JSON.parse(body) rescue JSON::ParserError nil end end |
Instance Method Details
#json ⇒ Hash, ...
The response body parsed as JSON.
60 61 62 63 64 65 66 |
# File 'lib/kitchen/driver/azure/http.rb', line 60 def json return nil if body.nil? || body.empty? JSON.parse(body) rescue JSON::ParserError nil end |
#success? ⇒ Boolean
Returns whether the status is in the 2xx range.
53 54 55 |
# File 'lib/kitchen/driver/azure/http.rb', line 53 def success? status.between?(200, 299) end |