Class: Scalr::Response
- Inherits:
-
Object
- Object
- Scalr::Response
- Defined in:
- lib/scalr/response.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#error ⇒ Object
Returns the value of attribute error.
-
#message ⇒ Object
Returns the value of attribute message.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(response, data) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #successful_request? ⇒ Boolean
Constructor Details
#initialize(response, data) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 15 |
# File 'lib/scalr/response.rb', line 8 def initialize(response, data) @code = response.code @message = response. if successful_request? @value = parse(data) @error = @value[:error][:message] if !success? end end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
6 7 8 |
# File 'lib/scalr/response.rb', line 6 def code @code end |
#error ⇒ Object
Returns the value of attribute error.
6 7 8 |
# File 'lib/scalr/response.rb', line 6 def error @error end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/scalr/response.rb', line 6 def @message end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/scalr/response.rb', line 6 def value @value end |
Instance Method Details
#failed? ⇒ Boolean
25 26 27 |
# File 'lib/scalr/response.rb', line 25 def failed? !success? end |
#success? ⇒ Boolean
21 22 23 |
# File 'lib/scalr/response.rb', line 21 def success? (successful_request? && @value[:error].nil?) end |
#successful_request? ⇒ Boolean
17 18 19 |
# File 'lib/scalr/response.rb', line 17 def successful_request? (@code == '200') end |