Class: RubstApi::TestResponse
- Inherits:
-
Object
- Object
- RubstApi::TestResponse
- Defined in:
- lib/rubst_api/test_client.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
(also: #status_code)
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status, headers, body) ⇒ TestResponse
constructor
A new instance of TestResponse.
- #json ⇒ Object
- #success? ⇒ Boolean
- #text ⇒ Object
Constructor Details
#initialize(status, headers, body) ⇒ TestResponse
Returns a new instance of TestResponse.
6 7 8 9 10 |
# File 'lib/rubst_api/test_client.rb', line 6 def initialize(status, headers, body) @status, @headers = status, Headers.new(headers) @body = body.respond_to?(:each) ? body.to_a.join : body.to_s body.close if body.respond_to?(:close) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/rubst_api/test_client.rb', line 5 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/rubst_api/test_client.rb', line 5 def headers @headers end |
#status ⇒ Object (readonly) Also known as: status_code
Returns the value of attribute status.
5 6 7 |
# File 'lib/rubst_api/test_client.rb', line 5 def status @status end |
Instance Method Details
#json ⇒ Object
12 |
# File 'lib/rubst_api/test_client.rb', line 12 def json = JSON.parse(body) |
#success? ⇒ Boolean
14 |
# File 'lib/rubst_api/test_client.rb', line 14 def success? = status.between?(200, 299) |
#text ⇒ Object
13 |
# File 'lib/rubst_api/test_client.rb', line 13 def text = body |