Class: Tire::HTTP::Response
- Inherits:
-
Object
- Object
- Tire::HTTP::Response
- Defined in:
- lib/tire/http/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(body, code, headers = {}) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(body, code, headers = {}) ⇒ Response
Returns a new instance of Response.
8 9 10 |
# File 'lib/tire/http/response.rb', line 8 def initialize(body, code, headers={}) @body, @code, @headers = body, code.to_i, headers end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/tire/http/response.rb', line 6 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/tire/http/response.rb', line 6 def code @code end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/tire/http/response.rb', line 6 def headers @headers end |
Instance Method Details
#failure? ⇒ Boolean
16 17 18 |
# File 'lib/tire/http/response.rb', line 16 def failure? ! success? end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/tire/http/response.rb', line 12 def success? code > 0 && code < 400 end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/tire/http/response.rb', line 20 def to_s [code, body].join(' : ') end |