Class: Marathon::Response
- Inherits:
-
Object
- Object
- Marathon::Response
- Defined in:
- lib/marathon/response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
TODO make this attr_reader and set the error some other way.
Class Method Summary collapse
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(http) ⇒ Response
constructor
A new instance of Response.
- #parsed_response ⇒ Object
- #success? ⇒ Boolean
- #to_s ⇒ Object
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 = end |
Instance Attribute Details
#error ⇒ Object
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() error = new(nil) error.error = error end |
Instance Method Details
#error? ⇒ Boolean
16 17 18 |
# File 'lib/marathon/response.rb', line 16 def error? !success? end |
#parsed_response ⇒ Object
20 21 22 |
# File 'lib/marathon/response.rb', line 20 def parsed_response @http && @http.parsed_response end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/marathon/response.rb', line 12 def success? @http && @http.success? end |
#to_s ⇒ Object
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 |