Class: HTTPalooza::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/httpalooza/response.rb

Constant Summary collapse

AwesomeResponseCodes =
200..299

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/httpalooza/response.rb', line 5

def body
  @body
end

#codeObject

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

Returns:

  • (Boolean)


12
13
14
# File 'lib/httpalooza/response.rb', line 12

def awesome?
  AwesomeResponseCodes.include?(code)
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


24
25
26
# File 'lib/httpalooza/response.rb', line 24

def eql?(other)
  self.class == other.class && code == other.code && body == other.body
end

#hashObject



30
31
32
# File 'lib/httpalooza/response.rb', line 30

def hash
  body.hash ^ code.hash
end

#inspectObject



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

Returns:

  • (Boolean)


16
17
18
# File 'lib/httpalooza/response.rb', line 16

def not_awesome?
  !awesome?
end