Class: HTTPalooza::Response
- Inherits:
-
Object
- Object
- HTTPalooza::Response
- Defined in:
- lib/httpalooza/response.rb
Constant Summary collapse
- AwesomeResponseCodes =
200..299
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
Instance Method Summary collapse
- #awesome? ⇒ Boolean
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(code, body) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #not_awesome? ⇒ Boolean
Constructor Details
#initialize(code, body) ⇒ Response
Returns a new instance of Response.
7 8 9 10 |
# File 'lib/httpalooza/response.rb', line 7 def initialize(code, body) @code = code.to_i @body = body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/httpalooza/response.rb', line 5 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
5 6 7 |
# File 'lib/httpalooza/response.rb', line 5 def code @code end |
Instance Method Details
#awesome? ⇒ Boolean
12 13 14 |
# File 'lib/httpalooza/response.rb', line 12 def awesome? AwesomeResponseCodes.include?(code) end |
#eql?(other) ⇒ Boolean Also known as: ==
24 25 26 |
# File 'lib/httpalooza/response.rb', line 24 def eql?(other) self.class == other.class && code == other.code && body == other.body end |
#hash ⇒ Object
30 31 32 |
# File 'lib/httpalooza/response.rb', line 30 def hash body.hash ^ code.hash end |
#inspect ⇒ Object
20 21 22 |
# File 'lib/httpalooza/response.rb', line 20 def inspect "<HTTPalooza::Response:#{object_id} code=#{code} body=#{body.to_s.inspect.truncate(30)}" end |
#not_awesome? ⇒ Boolean
16 17 18 |
# File 'lib/httpalooza/response.rb', line 16 def not_awesome? !awesome? end |