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
Prepares and runs an API command by shelling out to
name
, optionally withargs
orinput
. -
#success? ⇒ Boolean
Returns
true
if your request to the agent completed successfully.
Constructor Details
#initialize(name, args, input, options) ⇒ Command
Prepares and runs an API command by shelling out to name
, optionally with args
or input
. You can also set options
for the run, like :background => true
.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/scout_agent/api.rb', line 26 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?().
46 47 48 |
# File 'lib/scout_agent/api.rb', line 46 def @error_message end |
#exit_status ⇒ Object (readonly) Also known as: error_code
Returns the exit status of the agent command as an Integer.
39 40 41 |
# File 'lib/scout_agent/api.rb', line 39 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
.
61 62 63 |
# File 'lib/scout_agent/api.rb', line 61 def finished? @finished end |
#success? ⇒ Boolean
Returns true
if your request to the agent completed successfully.
49 50 51 |
# File 'lib/scout_agent/api.rb', line 49 def success? exit_status and exit_status.zero? end |