Class: ProcessExecuter::Status
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProcessExecuter::Status
- Extended by:
- Forwardable
- Defined in:
- lib/process_executer/status.rb
Overview
A simple delegator for Process::Status that adds a timeout? attribute
Instance Attribute Summary collapse
-
#timeout? ⇒ Boolean
readonly
True if the process timed out and was sent the SIGKILL signal.
-
#timeout_duration ⇒ Numeric?
readonly
The secs the command ran before being killed OR o or nil for no timeout.
Instance Method Summary collapse
-
#initialize(status, timeout, timeout_duration) ⇒ Status
constructor
Create a new Status object from a Process::Status and timeout flag.
-
#success? ⇒ Boolean?
Overrides the default success? method to return nil if the process timed out.
-
#to_s ⇒ String
Return a string representation of the status.
Constructor Details
#initialize(status, timeout, timeout_duration) ⇒ Status
Create a new Status object from a Process::Status and timeout flag
27 28 29 30 31 |
# File 'lib/process_executer/status.rb', line 27 def initialize(status, timeout, timeout_duration) super(status) @timeout = timeout @timeout_duration = timeout_duration end |
Instance Attribute Details
#timeout? ⇒ Boolean (readonly)
True if the process timed out and was sent the SIGKILL signal
46 |
# File 'lib/process_executer/status.rb', line 46 def timeout? = @timeout |
#timeout_duration ⇒ Numeric? (readonly)
The secs the command ran before being killed OR o or nil for no timeout
37 38 39 |
# File 'lib/process_executer/status.rb', line 37 def timeout_duration @timeout_duration end |
Instance Method Details
#success? ⇒ Boolean?
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
56 57 58 59 60 |
# File 'lib/process_executer/status.rb', line 56 def success? return nil if timeout? # rubocop:disable Style/ReturnNilInPredicateMethodDefinition super end |
#to_s ⇒ String
Return a string representation of the status
66 67 68 |
# File 'lib/process_executer/status.rb', line 66 def to_s "#{super}#{timeout? ? " timed out after #{timeout_duration}s" : ''}" end |