Class: Daengine::HTTP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/daengine/http_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



54
55
56
# File 'lib/daengine/http_client.rb', line 54

def initialize(response)
  @resp = response
end

Instance Method Details

#as_hashObject



70
71
72
# File 'lib/daengine/http_client.rb', line 70

def as_hash
  @resp.parsed_response
end

#bodyObject



62
63
64
# File 'lib/daengine/http_client.rb', line 62

def body
  @resp.body
end

#client_error?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/daengine/http_client.rb', line 89

def client_error?
  !!(status.to_s =~ /^4/)
end

#failed?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/daengine/http_client.rb', line 81

def failed?
  !success?
end

#headersObject



58
59
60
# File 'lib/daengine/http_client.rb', line 58

def headers
  @resp.headers
end

#redirection?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/daengine/http_client.rb', line 93

def redirection?
  !!(status.to_s =~ /^3/)
end

#server_error?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/daengine/http_client.rb', line 85

def server_error?
  !!(status.to_s =~ /^5/)
end

#statusObject Also known as: code, status_code



66
67
68
# File 'lib/daengine/http_client.rb', line 66

def status
  @resp.code
end

#success?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/daengine/http_client.rb', line 77

def success?
  !!(status.to_s =~ /^2/)
end