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.
9 10 11 |
# File 'lib/tire/http/response.rb', line 9 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.
7 8 9 |
# File 'lib/tire/http/response.rb', line 7 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
7 8 9 |
# File 'lib/tire/http/response.rb', line 7 def code @code end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/tire/http/response.rb', line 7 def headers @headers end |
Instance Method Details
#failure? ⇒ Boolean
17 18 19 |
# File 'lib/tire/http/response.rb', line 17 def failure? ! success? end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/tire/http/response.rb', line 13 def success? code > 0 && code < 400 end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/tire/http/response.rb', line 21 def to_s [code, body].join(' : ') end |