Class: Aidp::ShellExecutor::Result
- Inherits:
-
Object
- Object
- Aidp::ShellExecutor::Result
- Defined in:
- lib/aidp/shell_executor.rb
Overview
Immutable result of a shell-free command execution
Instance Attribute Summary collapse
-
#exit_status ⇒ Object
readonly
Returns the value of attribute exit_status.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(stdout:, stderr:, exit_status:) ⇒ Result
constructor
A new instance of Result.
-
#output ⇒ String
Combined output, equivalent to shell
2>&1redirection. -
#success? ⇒ Boolean
True if exit_status is 0.
Constructor Details
#initialize(stdout:, stderr:, exit_status:) ⇒ Result
Returns a new instance of Result.
36 37 38 39 40 41 |
# File 'lib/aidp/shell_executor.rb', line 36 def initialize(stdout:, stderr:, exit_status:) @stdout = stdout.to_s.freeze @stderr = stderr.to_s.freeze @exit_status = exit_status || 1 freeze end |
Instance Attribute Details
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status.
31 32 33 |
# File 'lib/aidp/shell_executor.rb', line 31 def exit_status @exit_status end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
31 32 33 |
# File 'lib/aidp/shell_executor.rb', line 31 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
31 32 33 |
# File 'lib/aidp/shell_executor.rb', line 31 def stdout @stdout end |
Instance Method Details
#output ⇒ String
Combined output, equivalent to shell 2>&1 redirection
50 51 52 |
# File 'lib/aidp/shell_executor.rb', line 50 def output [@stdout, @stderr].reject(&:empty?).join("\n") end |
#success? ⇒ Boolean
Returns true if exit_status is 0.
44 45 46 |
# File 'lib/aidp/shell_executor.rb', line 44 def success? @exit_status.zero? end |