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.
33 34 35 |
# File 'lib/sevgi/function/shell.rb', line 33 def args @args end |
#errs ⇒ Array<String>
Returns captured stderr lines.
33 34 35 |
# File 'lib/sevgi/function/shell.rb', line 33 def errs @errs end |
#exit_code ⇒ Integer?
Returns process exit code.
33 34 35 |
# File 'lib/sevgi/function/shell.rb', line 33 def exit_code @exit_code end |
#outs ⇒ Array<String>
Returns captured stdout lines.
33 34 35 |
# File 'lib/sevgi/function/shell.rb', line 33 def outs @outs end |
Class Method Details
.dummy ⇒ Sevgi::Function::Shell::Result
Builds a successful empty result.
73 |
# File 'lib/sevgi/function/shell.rb', line 73 def self.dummy = new([], [], [], 0) |
Instance Method Details
#all ⇒ String
Returns stdout, a separator, and stderr as one string.
45 |
# File 'lib/sevgi/function/shell.rb', line 45 def all = [*outs, "\n\n", *errs].join("\n").strip |
#cmd ⇒ String
Returns the command as a shell-like display string.
49 |
# File 'lib/sevgi/function/shell.rb', line 49 def cmd = args.join(" ") |
#err ⇒ String
Returns captured stderr as a string.
53 |
# File 'lib/sevgi/function/shell.rb', line 53 def err = errs.join("\n") |
#notok? ⇒ Boolean
Reports whether the command failed.
57 |
# File 'lib/sevgi/function/shell.rb', line 57 def notok? = !ok? |
#ok? ⇒ Boolean
Reports whether the command exited successfully.
61 |
# File 'lib/sevgi/function/shell.rb', line 61 def ok? = exit_code&.zero? |
#out ⇒ String
Returns captured stdout as a string.
65 |
# File 'lib/sevgi/function/shell.rb', line 65 def out = outs.join("\n") |
#outline ⇒ String?
Returns the first stdout line.
69 |
# File 'lib/sevgi/function/shell.rb', line 69 def outline = outs.first |