Class: Hyperquest::Response
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Hyperquest::Response
- Extended by:
- Forwardable
- Defined in:
- lib/hyperquest/response.rb
Overview
Hyperquest::Response is a wrapper for responses from hyperquest.go
Attributes collapse
- #body ⇒ String readonly
- #content_length ⇒ Fixnum readonly
- #content_type ⇒ String readonly
- #error ⇒ String readonly
- #status ⇒ Fixnum readonly
-
#uri ⇒ String
readonly
Request url.
Attributes collapse
-
#failed? ⇒ Boolean
Returns true if error is not empty.
-
#success? ⇒ Boolean
Returns true if error is empty.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Response
constructor
private
Instantiated by Request - see Hyperquest::Request.open.
Constructor Details
#initialize(hash) ⇒ Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instantiated by Hyperquest::Request - see Hyperquest::Request.open
14 15 16 |
# File 'lib/hyperquest/response.rb', line 14 def initialize(hash) @response = OpenStruct.new(hash).freeze end |
Instance Attribute Details
#body ⇒ String (readonly)
31 32 33 |
# File 'lib/hyperquest/response.rb', line 31 def_delegators :@response, :uri, :content_length, :content_type, :body, :status, :error |
#content_length ⇒ Fixnum (readonly)
31 32 33 |
# File 'lib/hyperquest/response.rb', line 31 def_delegators :@response, :uri, :content_length, :content_type, :body, :status, :error |
#content_type ⇒ String (readonly)
31 32 33 |
# File 'lib/hyperquest/response.rb', line 31 def_delegators :@response, :uri, :content_length, :content_type, :body, :status, :error |
#error ⇒ String (readonly)
31 32 33 |
# File 'lib/hyperquest/response.rb', line 31 def_delegators :@response, :uri, :content_length, :content_type, :body, :status, :error |
#status ⇒ Fixnum (readonly)
31 32 33 |
# File 'lib/hyperquest/response.rb', line 31 def_delegators :@response, :uri, :content_length, :content_type, :body, :status, :error |
#uri ⇒ String (readonly)
Returns Request url.
31 32 33 |
# File 'lib/hyperquest/response.rb', line 31 def_delegators :@response, :uri, :content_length, :content_type, :body, :status, :error |
Instance Method Details
#failed? ⇒ Boolean
Returns true if error is not empty
43 44 45 |
# File 'lib/hyperquest/response.rb', line 43 def failed? !success? end |
#success? ⇒ Boolean
Returns true if error is empty
37 38 39 |
# File 'lib/hyperquest/response.rb', line 37 def success? error.empty? end |