Class: Marathon::Response

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Response

Returns a new instance of Response.



7
8
9
10
# File 'lib/marathon/response.rb', line 7

def initialize(http)
  @http = http
  @error = error_message_from_response
end

Instance Attribute Details

#errorObject

TODO make this attr_reader and set the error some other way



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

def error
  @error
end

Class Method Details

.error(message) ⇒ Object



24
25
26
27
28
# File 'lib/marathon/response.rb', line 24

def self.error(message)
  error = new(nil)
  error.error = message
  error
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


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

def error?
  !success?
end

#parsed_responseObject



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

def parsed_response
  @http && @http.parsed_response
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  @http && @http.success?
end

#to_sObject



30
31
32
33
34
35
36
# File 'lib/marathon/response.rb', line 30

def to_s
  if success?
    "OK"
  else
    "ERROR: #{error}"
  end
end