Class: Trav3::Response
- Inherits:
-
Object
- Object
- Trav3::Response
- Extended by:
- Forwardable
- Defined in:
- lib/trav3/response/response.rb
Overview
The results from queries return either Success
or RequestError
which both repsond with Hash like query methods for the JSON data or the Net::HTTP resonse object methods.
The Response
classes Success
and RequestError
forward method calls for all of the instance methods of a ResponseCollection
to the collection. And many of the methods calls for the Net::HTTP response are also available on this class and those method calls are forwarded to the response.
Direct Known Subclasses
Instance Method Summary collapse
-
#[] ⇒ Object
Forwards to :@collection.
-
#body ⇒ Object
Forwards to :@response.
-
#code ⇒ Object
Forwards to :@response.
-
#code_type ⇒ Object
Forwards to :@response.
-
#count ⇒ Object
Forwards to :@collection.
-
#decode_content ⇒ Object
Forwards to :@response.
-
#dig ⇒ Object
Forwards to :@collection.
-
#each ⇒ Object
Forwards to :@collection.
-
#each_header ⇒ Object
Forwards to :@response.
-
#empty? ⇒ Object
Forwards to :@collection.
-
#entity ⇒ Object
Forwards to :@response.
- #failure? ⇒ Boolean abstract
-
#fetch ⇒ Object
Forwards to :@collection.
-
#first ⇒ Object
Forwards to :@collection.
-
#follow ⇒ Object
Forwards to :@collection.
-
#get_fields ⇒ Object
Forwards to :@response.
-
#has_key? ⇒ Object
Forwards to :@collection.
-
#hash? ⇒ Object
Forwards to :@collection.
-
#header ⇒ Object
Forwards to :@response.
-
#http_version ⇒ Object
Forwards to :@response.
-
#initialize(travis, response) ⇒ Response
constructor
A new instance of Response.
-
#inspect ⇒ Object
Class name and keys of response.
-
#key? ⇒ Object
Forwards to :@collection.
-
#keys ⇒ Object
Forwards to :@collection.
-
#last ⇒ Object
Forwards to :@collection.
-
#message ⇒ Object
Forwards to :@response.
-
#msg ⇒ Object
Forwards to :@response.
-
#read_body ⇒ Object
Forwards to :@response.
-
#read_header ⇒ Object
Forwards to :@response.
-
#reading_body ⇒ Object
Forwards to :@response.
-
#response ⇒ Object
Forwards to :@response.
- #success? ⇒ Boolean abstract
-
#uri ⇒ Object
Forwards to :@response.
-
#value ⇒ Object
Forwards to :@response.
-
#values ⇒ Object
Forwards to :@collection.
Constructor Details
#initialize(travis, response) ⇒ Response
Returns a new instance of Response
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/trav3/response/response.rb', line 115 def initialize(travis, response) @travis = travis @response = response @collection = begin result = JSON.parse(response&.body || '{}') ResponseCollection.new(travis, result) rescue JSON::ParserError response.error! end end |
Instance Method Details
#[] ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#body ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#code ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#code_type ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#count ⇒ Object
Forwards to :@collection.
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#decode_content ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#dig ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#each ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#each_header ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#empty? ⇒ Object
Forwards to :@collection.
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#entity ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#failure? ⇒ Boolean
137 138 139 |
# File 'lib/trav3/response/response.rb', line 137 def failure? raise Unimplemented end |
#fetch ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#first ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#follow ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#get_fields ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#has_key? ⇒ Object
Forwards to :@collection.
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#hash? ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#header ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#http_version ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#inspect ⇒ Object
Class name and keys of response
127 128 129 |
# File 'lib/trav3/response/response.rb', line 127 def inspect "<#{self.class} Response: keys = #{keys}>" end |
#key? ⇒ Object
Forwards to :@collection.
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#keys ⇒ Object
Forwards to :@collection.
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#last ⇒ Object
Forwards to :@collection
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |
#message ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#msg ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#read_body ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#read_header ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#reading_body ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#response ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#success? ⇒ Boolean
132 133 134 |
# File 'lib/trav3/response/response.rb', line 132 def success? raise Unimplemented end |
#uri ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#value ⇒ Object
Forwards to :@response
111 112 113 114 |
# File 'lib/trav3/response/response.rb', line 111 def_delegators :@response, :body, :code, :code_type, :decode_content, :each_header, :entity, :get_fields, :header, :http_version, :message, :msg, :read_body, :read_header, :reading_body, :response, :uri, :value |
#values ⇒ Object
Forwards to :@collection.
58 |
# File 'lib/trav3/response/response.rb', line 58 def_delegators :@collection, *ResponseCollection.instance_methods(false) |