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.



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

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

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

Returns:

  • (Boolean)


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

def failure?
  ! success?
end

#success?Boolean

Returns:

  • (Boolean)


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

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

#to_sObject



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

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