Class: ProcessExecuter::Command::Result
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ProcessExecuter::Command::Result
- Defined in:
- lib/process_executer/command/result.rb
Overview
A wrapper around Status which adds captured command output
This class is used to represent the result of a subprocess execution, combining the process status with the captured output for easier access and manipulation.
Features:
- Provides access to the process's status, stdout, and stderr.
- Allows conversion of stdout and stderr buffers to strings.
Instance Attribute Summary collapse
-
#command ⇒ Array<String>
readonly
The command that was run.
-
#stderr ⇒ String
readonly
The captured stderr output from the process.
-
#stdout ⇒ String
readonly
The captured stdout output from the process.
Instance Method Summary collapse
-
#initialize(command, status, stdout, stderr) ⇒ Result
constructor
Create a new Result object.
-
#stderr_to_s ⇒ String, Object
Return the stderr output as a string.
-
#stdout_to_s ⇒ String, Object
Return the stdout output as a string.
Constructor Details
#initialize(command, status, stdout, stderr) ⇒ Result
Create a new Result object
31 32 33 34 35 36 |
# File 'lib/process_executer/command/result.rb', line 31 def initialize(command, status, stdout, stderr) super(status) @command = command @stdout = stdout @stderr = stderr end |
Instance Attribute Details
#command ⇒ Array<String> (readonly)
The command that was run
42 43 44 |
# File 'lib/process_executer/command/result.rb', line 42 def command @command end |
#stderr ⇒ String (readonly)
The captured stderr output from the process
54 55 56 |
# File 'lib/process_executer/command/result.rb', line 54 def stderr @stderr end |
#stdout ⇒ String (readonly)
The captured stdout output from the process
48 49 50 |
# File 'lib/process_executer/command/result.rb', line 48 def stdout @stdout end |
Instance Method Details
#stderr_to_s ⇒ String, Object
Return the stderr output as a string
72 73 74 |
# File 'lib/process_executer/command/result.rb', line 72 def stderr_to_s stderr.respond_to?(:string) ? stderr.string : stderr end |
#stdout_to_s ⇒ String, Object
Return the stdout output as a string
62 63 64 |
# File 'lib/process_executer/command/result.rb', line 62 def stdout_to_s stdout.respond_to?(:string) ? stdout.string : stdout end |