Class: Tire::HTTP::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/tire/http/response.rb', line 6

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/tire/http/response.rb', line 6

def code
  @code
end

#headersObject (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

Returns:

  • (Boolean)


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

def failure?
  ! success?
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  code > 0 && code < 400
end

#to_sObject



20
21
22
# File 'lib/tire/http/response.rb', line 20

def to_s
  [code, body].join(' : ')
end