Class: Botiasloop::Tools::Shell::Result
- Inherits:
-
Object
- Object
- Botiasloop::Tools::Shell::Result
- Defined in:
- lib/botiasloop/tools/shell.rb
Overview
Result wrapper for shell execution
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#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_code) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(stdout, stderr, exit_code) ⇒ Result
Returns a new instance of Result.
30 31 32 33 34 |
# File 'lib/botiasloop/tools/shell.rb', line 30 def initialize(stdout, stderr, exit_code) @stdout = stdout @stderr = stderr @exit_code = exit_code end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
28 29 30 |
# File 'lib/botiasloop/tools/shell.rb', line 28 def exit_code @exit_code end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
28 29 30 |
# File 'lib/botiasloop/tools/shell.rb', line 28 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
28 29 30 |
# File 'lib/botiasloop/tools/shell.rb', line 28 def stdout @stdout end |
Instance Method Details
#success? ⇒ Boolean
36 37 38 |
# File 'lib/botiasloop/tools/shell.rb', line 36 def success? @exit_code == 0 end |
#to_h ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/botiasloop/tools/shell.rb', line 44 def to_h { stdout: @stdout, stderr: @stderr, exit_code: @exit_code, success?: success? } end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/botiasloop/tools/shell.rb', line 40 def to_s "Exit: #{@exit_code}\nStdout:\n#{@stdout}\nStderr:\n#{@stderr}" end |