Class: Rubsh::RunningPipeline
- Inherits:
-
Object
- Object
- Rubsh::RunningPipeline
- Defined in:
- lib/rubsh/running_pipeline.rb
Constant Summary collapse
- SPECIAL_KWARGS =
%i[ _in_data _in _out _err _err_to_out _capture _bg _env _timeout _cwd _ok_code _out_bufsize _err_bufsize _no_out _no_err ]
Instance Attribute Summary collapse
- #exit_code ⇒ Number readonly
- #finished_at ⇒ Time readonly
- #started_at ⇒ Time readonly
- #stderr_data ⇒ String readonly
- #stdout_data ⇒ String readonly
Instance Method Summary collapse
-
#initialize(sh) ⇒ RunningPipeline
constructor
A new instance of RunningPipeline.
- #ok? ⇒ Boolean
- #to_s ⇒ String
- #wait(timeout: nil) ⇒ void
- #wall_time ⇒ Numeric? (also: #execution_time)
Constructor Details
#initialize(sh) ⇒ RunningPipeline
Returns a new instance of RunningPipeline.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rubsh/running_pipeline.rb', line 41 def initialize(sh) @sh = sh @rcmds = [] # Runtime @prog_with_args = nil @exit_code = nil @started_at = nil @finished_at = nil @stdout_data = "".force_encoding(::Encoding.default_external) @stderr_data = "".force_encoding(::Encoding.default_external) @in_rd = nil @in_wr = nil @out_rd = nil @out_wr = nil @err_rd = nil @err_wr = nil @out_rd_reader = nil @err_rd_reader = nil @waiters = [] # Special Kwargs - Controlling Input/Output @_in_data = nil @_in = nil @_out = nil @_err = nil @_err_to_out = false @_capture = nil # Special Kwargs - Execution @_bg = false @_env = nil @_timeout = nil @_cwd = nil @_ok_code = [0] # Special Kwargs - Performance & Optimization @_out_bufsize = 0 @_err_bufsize = 0 @_no_out = false @_no_err = false end |
Instance Attribute Details
#exit_code ⇒ Number (readonly)
23 24 25 |
# File 'lib/rubsh/running_pipeline.rb', line 23 def exit_code @exit_code end |
#finished_at ⇒ Time (readonly)
31 32 33 |
# File 'lib/rubsh/running_pipeline.rb', line 31 def finished_at @finished_at end |
#started_at ⇒ Time (readonly)
27 28 29 |
# File 'lib/rubsh/running_pipeline.rb', line 27 def started_at @started_at end |
#stderr_data ⇒ String (readonly)
39 40 41 |
# File 'lib/rubsh/running_pipeline.rb', line 39 def stderr_data @stderr_data end |
#stdout_data ⇒ String (readonly)
35 36 37 |
# File 'lib/rubsh/running_pipeline.rb', line 35 def stdout_data @stdout_data end |
Instance Method Details
#ok? ⇒ Boolean
91 92 93 |
# File 'lib/rubsh/running_pipeline.rb', line 91 def ok? @_ok_code.include?(@exit_code) end |
#to_s ⇒ String
102 103 104 |
# File 'lib/rubsh/running_pipeline.rb', line 102 def to_s @prog_with_args end |
#wait(timeout: nil) ⇒ void
This method returns an undefined value.
96 97 98 99 |
# File 'lib/rubsh/running_pipeline.rb', line 96 def wait(timeout: nil) wait2(timeout: timeout) handle_return_code end |
#wall_time ⇒ Numeric? Also known as: execution_time
85 86 87 |
# File 'lib/rubsh/running_pipeline.rb', line 85 def wall_time @finished_at.nil? ? nil : @finished_at - @started_at end |