Class: ProcessExecuter::Result
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProcessExecuter::Result
- Defined in:
- lib/process_executer/result.rb
Overview
A decorator for Process::Status that adds the following attributes:
command
: the command that was used to spawn the processoptions
: the options that were used to spawn the processelapsed_time
: the seconds the command rantimed_out?
: true if the process timed out
Instance Attribute Summary collapse
-
#command ⇒ Array
readonly
The command that was used to spawn the process.
-
#elapsed_time ⇒ Numeric
readonly
The seconds the command ran.
-
#options ⇒ ProcessExecuter::Options::Base
readonly
The options that were used to spawn the process.
-
#timed_out ⇒ Boolean
(also: #timed_out?)
readonly
True if the process timed out and was sent the SIGKILL signal.
Instance Method Summary collapse
-
#initialize(status, command:, options:, timed_out:, elapsed_time:) ⇒ Result
constructor
Create a new Result object.
-
#success? ⇒ true, ...
Overrides the default
success?
method to returnnil
if the process timed out. -
#to_s ⇒ String
Return a string representation of the result.
Constructor Details
#initialize(status, command:, options:, timed_out:, elapsed_time:) ⇒ Result
Create a new Result object
38 39 40 41 42 43 44 |
# File 'lib/process_executer/result.rb', line 38 def initialize(status, command:, options:, timed_out:, elapsed_time:) super(status) @command = command @options = @timed_out = timed_out @elapsed_time = elapsed_time end |
Instance Attribute Details
#command ⇒ Array (readonly)
The command that was used to spawn the process
51 52 53 |
# File 'lib/process_executer/result.rb', line 51 def command @command end |
#elapsed_time ⇒ Numeric (readonly)
The seconds the command ran
70 71 72 |
# File 'lib/process_executer/result.rb', line 70 def elapsed_time @elapsed_time end |
#options ⇒ ProcessExecuter::Options::Base (readonly)
The options that were used to spawn the process
64 65 66 |
# File 'lib/process_executer/result.rb', line 64 def @options end |
#timed_out ⇒ Boolean (readonly) Also known as: timed_out?
True if the process timed out and was sent the SIGKILL signal
79 80 81 |
# File 'lib/process_executer/result.rb', line 79 def timed_out @timed_out end |
Instance Method Details
#success? ⇒ true, ...
Overrides the default success?
method to return nil
if the process timed out
This is because when a timeout occurs, Windows will still return true.
91 92 93 94 95 |
# File 'lib/process_executer/result.rb', line 91 def success? return nil if timed_out? # rubocop:disable Style/ReturnNilInPredicateMethodDefinition super end |
#to_s ⇒ String
Return a string representation of the result
104 105 106 |
# File 'lib/process_executer/result.rb', line 104 def to_s "#{super}#{" timed out after #{.timeout_after}s" if timed_out?}" end |