Class: Methadone::ProcessStatus
- Inherits:
-
Object
- Object
- Methadone::ProcessStatus
- Defined in:
- lib/methadone/process_status.rb
Overview
Methadone Internal - treat as private
A wrapper/enhancement of Process::Status that handles coersion and expected nonzero statuses
Instance Attribute Summary collapse
-
#exitstatus ⇒ Object
readonly
The exit status, either directly from a Process::Status or derived from a non-Int value.
Instance Method Summary collapse
-
#initialize(status, expected) ⇒ ProcessStatus
constructor
Create the ProcessStatus with the given status.
-
#success? ⇒ Boolean
True if the exit status was a successul (i.e. expected) one.
Constructor Details
#initialize(status, expected) ⇒ ProcessStatus
Create the ProcessStatus with the given status.
- status
-
if this responds to #exitstatus, that method is used to extract the exit code. If it’s and Int, that is used as the exit code. Otherwise, it’s truthiness is used: 0 for truthy, 1 for falsey.
- expected
-
an Int or Array of Int representing the expected exit status, other than zero, that represent “success”.
18 19 20 21 |
# File 'lib/methadone/process_status.rb', line 18 def initialize(status,expected) @exitstatus = derive_exitstatus(status) @success = ([0] + Array(expected)).include?(@exitstatus) end |
Instance Attribute Details
#exitstatus ⇒ Object (readonly)
The exit status, either directly from a Process::Status or derived from a non-Int value.
9 10 11 |
# File 'lib/methadone/process_status.rb', line 9 def exitstatus @exitstatus end |
Instance Method Details
#success? ⇒ Boolean
True if the exit status was a successul (i.e. expected) one.
24 25 26 |
# File 'lib/methadone/process_status.rb', line 24 def success? @success end |