Class: Sevgi::Function::Shell::Result
- Inherits:
-
Struct
- Object
- Struct
- Sevgi::Function::Shell::Result
- Defined in:
- lib/sevgi/function/shell.rb
Overview
Result object returned by shell commands.
Instance Attribute Summary collapse
-
#args ⇒ Array<String>
Command arguments.
-
#errs ⇒ Array<String>
Captured stderr lines.
-
#exit_code ⇒ Integer?
Process exit code.
-
#outs ⇒ Array<String>
Captured stdout lines.
Class Method Summary collapse
-
.dummy ⇒ Sevgi::Function::Shell::Result
Builds a successful empty result.
Instance Method Summary collapse
-
#all ⇒ String
Returns stdout, a separator, and stderr as one string.
-
#cmd ⇒ String
Returns the command as a shell-like display string.
-
#err ⇒ String
Returns captured stderr as a string.
-
#notok? ⇒ Boolean
Reports whether the command failed.
-
#ok? ⇒ Boolean
Reports whether the command exited successfully.
-
#out ⇒ String
Returns captured stdout as a string.
-
#outline ⇒ String?
Returns the first stdout line.
Instance Attribute Details
#args ⇒ Array<String>
Returns command arguments.
34 35 36 |
# File 'lib/sevgi/function/shell.rb', line 34 def args @args end |
#errs ⇒ Array<String>
Returns captured stderr lines.
34 35 36 |
# File 'lib/sevgi/function/shell.rb', line 34 def errs @errs end |
#exit_code ⇒ Integer?
Returns process exit code.
34 35 36 |
# File 'lib/sevgi/function/shell.rb', line 34 def exit_code @exit_code end |
#outs ⇒ Array<String>
Returns captured stdout lines.
34 35 36 |
# File 'lib/sevgi/function/shell.rb', line 34 def outs @outs end |
Class Method Details
.dummy ⇒ Sevgi::Function::Shell::Result
Builds a successful empty result.
74 |
# File 'lib/sevgi/function/shell.rb', line 74 def self.dummy = new([], [], [], 0) |
Instance Method Details
#all ⇒ String
Returns stdout, a separator, and stderr as one string.
46 |
# File 'lib/sevgi/function/shell.rb', line 46 def all = [*outs, "\n\n", *errs].join("\n").strip |
#cmd ⇒ String
Returns the command as a shell-like display string.
50 |
# File 'lib/sevgi/function/shell.rb', line 50 def cmd = args.join(" ") |
#err ⇒ String
Returns captured stderr as a string.
54 |
# File 'lib/sevgi/function/shell.rb', line 54 def err = errs.join("\n") |
#notok? ⇒ Boolean
Reports whether the command failed.
58 |
# File 'lib/sevgi/function/shell.rb', line 58 def notok? = !ok? |
#ok? ⇒ Boolean
Reports whether the command exited successfully.
62 |
# File 'lib/sevgi/function/shell.rb', line 62 def ok? = exit_code&.zero? |
#out ⇒ String
Returns captured stdout as a string.
66 |
# File 'lib/sevgi/function/shell.rb', line 66 def out = outs.join("\n") |
#outline ⇒ String?
Returns the first stdout line.
70 |
# File 'lib/sevgi/function/shell.rb', line 70 def outline = outs.first |