Class: Clowk::Http::Response
- Inherits:
-
Object
- Object
- Clowk::Http::Response
- Defined in:
- lib/clowk/http/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#body_parsed ⇒ Object
readonly
Returns the value of attribute body_parsed.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
-
#initialize(status:, body:, body_parsed:, headers:, success:) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(status:, body:, body_parsed:, headers:, success:) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 |
# File 'lib/clowk/http/response.rb', line 8 def initialize(status:, body:, body_parsed:, headers:, success:) @status = status @body = body @body_parsed = body_parsed @headers = headers @success = success end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/clowk/http/response.rb', line 6 def body @body end |
#body_parsed ⇒ Object (readonly)
Returns the value of attribute body_parsed.
6 7 8 |
# File 'lib/clowk/http/response.rb', line 6 def body_parsed @body_parsed end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/clowk/http/response.rb', line 6 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/clowk/http/response.rb', line 6 def status @status end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/clowk/http/response.rb', line 34 def ==(other) to_h == if other.respond_to?(:to_h) other.to_h else other end end |
#[](key) ⇒ Object
20 21 22 |
# File 'lib/clowk/http/response.rb', line 20 def [](key) to_h.fetch(key) end |
#success? ⇒ Boolean
16 17 18 |
# File 'lib/clowk/http/response.rb', line 16 def success? @success end |
#to_h ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/clowk/http/response.rb', line 24 def to_h { status: status, body: body, body_parsed: body_parsed, headers: headers, success: success? } end |