Class: ScalrResponse
- Inherits:
-
REXML::Document
- Object
- REXML::Document
- ScalrResponse
- Defined in:
- lib/rscalr/api/scalr.rb
Overview
Represents a response from an API call. Thin wrapper around an REXML::Document of the parsed repsonse.
Instance Method Summary collapse
-
#error_message ⇒ Object
If the API call was not successful, this returns the inner error message.
-
#initialize(http_response_body = nil) ⇒ ScalrResponse
constructor
A new instance of ScalrResponse.
-
#pretty_print(dest = $stdout) ⇒ Object
Convenience method to output a repsonse to a stream in a human readable format.
-
#success? ⇒ Boolean
True iff the response indicates that the API call succeeded.
Constructor Details
#initialize(http_response_body = nil) ⇒ ScalrResponse
Returns a new instance of ScalrResponse.
377 378 379 380 381 382 383 |
# File 'lib/rscalr/api/scalr.rb', line 377 def initialize http_response_body=nil if http_response_body.nil? super else super http_response_body end end |
Instance Method Details
#error_message ⇒ Object
If the API call was not successful, this returns the inner error message.
393 394 395 396 397 398 399 |
# File 'lib/rscalr/api/scalr.rb', line 393 def if success? nil else root.elements['Message'].text end end |
#pretty_print(dest = $stdout) ⇒ Object
Convenience method to output a repsonse to a stream in a human readable format
402 403 404 405 406 |
# File 'lib/rscalr/api/scalr.rb', line 402 def pretty_print(dest=$stdout) formatter = REXML::Formatters::Pretty.new formatter.compact = true formatter.write(root,dest) end |
#success? ⇒ Boolean
True iff the response indicates that the API call succeeded. This does not guarantee that the intent of the call succeeded of course (e.g. that a script executed successfully on the Scalr side), only that Scalr reported success for the call.
388 389 390 |
# File 'lib/rscalr/api/scalr.rb', line 388 def success? root.name != 'Error' end |