Class: ScoutAgent::API::Command
- Inherits:
-
Object
- Object
- ScoutAgent::API::Command
- Defined in:
- lib/scout_agent/api.rb
Overview
You should not need to consruct instances of this class directly as the API will handle those details for you. However, you can use the methods of these instances, returned by many API methods, to examine the success or failure of your requests.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
Returns the error message from the agent as a Sting.
-
#exit_status ⇒ Object
(also: #error_code)
readonly
Returns the exit status of the agent command as an Integer.
Instance Method Summary collapse
-
#finished? ⇒ Boolean
Returns
true
if you chose to run the request in the background and it is now complete. -
#initialize(name, args, input, options) ⇒ Command
constructor
:nodoc:.
-
#success? ⇒ Boolean
Returns
true
if your request to the agent completed successfully.
Constructor Details
#initialize(name, args, input, options) ⇒ Command
:nodoc:
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/scout_agent/api.rb', line 32 def initialize(name, args, input, ) # :nodoc: @name = name @args = args @input = input @background = [:background] @exit_status = nil @error_message = nil @finished = false @background ? run_in_background : run end |
Instance Attribute Details
#error_message ⇒ Object (readonly)
Returns the error message from the agent as a Sting. This is only set if the request was not a success?().
52 53 54 |
# File 'lib/scout_agent/api.rb', line 52 def @error_message end |
#exit_status ⇒ Object (readonly) Also known as: error_code
Returns the exit status of the agent command as an Integer.
45 46 47 |
# File 'lib/scout_agent/api.rb', line 45 def exit_status @exit_status end |
Instance Method Details
#finished? ⇒ Boolean
Returns true
if you chose to run the request in the background and it is now complete. You can periodically poll this method to see if a background request has completed yet.
Warning: none of the other methods should be trusted until this method returns true
.
67 68 69 |
# File 'lib/scout_agent/api.rb', line 67 def finished? @finished end |
#success? ⇒ Boolean
Returns true
if your request to the agent completed successfully.
55 56 57 |
# File 'lib/scout_agent/api.rb', line 55 def success? exit_status and exit_status.zero? end |