Class: HTTPalooza::Response
- Inherits:
-
Object
- Object
- HTTPalooza::Response
- Defined in:
- lib/httpalooza/response.rb
Overview
Response represents a unified interface for the various Player’s responses.
Constant Summary collapse
- AwesomeResponseCodes =
200..299
Instance Attribute Summary collapse
-
#body ⇒ String
The HTTP response body.
-
#code ⇒ Fixnum
The HTTP status code.
Instance Method Summary collapse
-
#awesome? ⇒ Boolean
Whether or not the response code was awesome.
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(code, body) ⇒ Response
constructor
Create a new Response.
- #inspect ⇒ Object
-
#not_awesome? ⇒ Boolean
Whether or not the response code was not awesome.
Constructor Details
#initialize(code, body) ⇒ Response
Create a new Response.
16 17 18 19 |
# File 'lib/httpalooza/response.rb', line 16 def initialize(code, body) @code = code.to_i @body = body end |
Instance Attribute Details
#body ⇒ String
Returns the HTTP response body.
10 |
# File 'lib/httpalooza/response.rb', line 10 attr_accessor :code, :body |
#code ⇒ Fixnum
Returns the HTTP status code.
10 11 12 |
# File 'lib/httpalooza/response.rb', line 10 def code @code end |
Instance Method Details
#awesome? ⇒ Boolean
Returns whether or not the response code was awesome.
22 23 24 |
# File 'lib/httpalooza/response.rb', line 22 def awesome? AwesomeResponseCodes.include?(code) end |
#eql?(other) ⇒ Boolean Also known as: ==
35 36 37 |
# File 'lib/httpalooza/response.rb', line 35 def eql?(other) self.class == other.class && code == other.code && body == other.body end |
#hash ⇒ Object
41 42 43 |
# File 'lib/httpalooza/response.rb', line 41 def hash body.hash ^ code.hash end |
#inspect ⇒ Object
31 32 33 |
# File 'lib/httpalooza/response.rb', line 31 def inspect "<HTTPalooza::Response:#{object_id} code=#{code} body=#{body.to_s.inspect.truncate(30)}" end |
#not_awesome? ⇒ Boolean
Returns whether or not the response code was not awesome.
27 28 29 |
# File 'lib/httpalooza/response.rb', line 27 def not_awesome? !awesome? end |