Class: Soren::Response
Class Method Summary collapse
-
.from_parts(code:, message:, version:, headers:, body:) ⇒ Object
: (code: Integer, message: String, version: String, headers: Hash[String, Array], body: String) -> Soren::Response.
Instance Method Summary collapse
-
#body ⇒ Object
: -> String.
-
#code ⇒ Object
: -> Integer.
-
#headers ⇒ Object
: -> Hash[String, Array].
-
#initialize(parsed_response) ⇒ Response
constructor
: (Hash[Symbol, untyped]) -> void.
-
#message ⇒ Object
: -> String.
-
#version ⇒ Object
: -> String.
Constructor Details
#initialize(parsed_response) ⇒ Response
: (Hash[Symbol, untyped]) -> void
14 15 16 17 18 19 20 21 22 |
# File 'lib/soren/response.rb', line 14 def initialize(parsed_response) parsed_status_line = parsed_response[:status_line] @version = parsed_status_line[:version] #: Soren::Types::Response::Version @code = parsed_status_line[:code] #: Soren::Types::Response::Code @message = parsed_status_line[:message] #: Soren::Types::Response::Message @headers = parsed_response[:headers] #: Soren::Types::Response::Headers @body = parsed_response[:body] #: Soren::Types::Response::Body end |
Class Method Details
.from_parts(code:, message:, version:, headers:, body:) ⇒ Object
: (code: Integer, message: String, version: String, headers: Hash[String, Array], body: String) -> Soren::Response
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/soren/response.rb', line 51 def from_parts(code:, message:, version:, headers:, body:) new({ status_line: { version: Types::Response::Version.new("HTTP/#{version}"), code: Types::Response::Code.new(code), message: Types::Response::Message.new(), }, headers: Types::Response::Headers.new(headers), body: Types::Response::Body.new(body), }) end |
Instance Method Details
#code ⇒ Object
: -> Integer
25 26 27 |
# File 'lib/soren/response.rb', line 25 def code @code.to_i end |
#headers ⇒ Object
: -> Hash[String, Array]
40 41 42 |
# File 'lib/soren/response.rb', line 40 def headers @headers.to_h end |
#message ⇒ Object
: -> String
30 31 32 |
# File 'lib/soren/response.rb', line 30 def @message.to_s end |
#version ⇒ Object
: -> String
35 36 37 |
# File 'lib/soren/response.rb', line 35 def version @version.to_s end |