Class: Sevgi::Function::Shell::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/sevgi/function/shell.rb

Overview

Result object returned by shell commands.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsArray<String>

Returns command arguments.

Returns:

  • (Array<String>)

    command arguments



33
34
35
# File 'lib/sevgi/function/shell.rb', line 33

def args
  @args
end

#errsArray<String>

Returns captured stderr lines.

Returns:

  • (Array<String>)

    captured stderr lines



33
34
35
# File 'lib/sevgi/function/shell.rb', line 33

def errs
  @errs
end

#exit_codeInteger?

Returns process exit code.

Returns:

  • (Integer, nil)

    process exit code



33
34
35
# File 'lib/sevgi/function/shell.rb', line 33

def exit_code
  @exit_code
end

#outsArray<String>

Returns captured stdout lines.

Returns:

  • (Array<String>)

    captured stdout lines



33
34
35
# File 'lib/sevgi/function/shell.rb', line 33

def outs
  @outs
end

Class Method Details

.dummySevgi::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

#allString

Returns stdout, a separator, and stderr as one string.

Returns:



45
# File 'lib/sevgi/function/shell.rb', line 45

def all = [*outs, "\n\n", *errs].join("\n").strip

#cmdString

Returns the command as a shell-like display string.

Returns:



49
# File 'lib/sevgi/function/shell.rb', line 49

def cmd = args.join(" ")

#errString

Returns captured stderr as a string.

Returns:



53
# File 'lib/sevgi/function/shell.rb', line 53

def err = errs.join("\n")

#notok?Boolean

Reports whether the command failed.

Returns:

  • (Boolean)


57
# File 'lib/sevgi/function/shell.rb', line 57

def notok? = !ok?

#ok?Boolean

Reports whether the command exited successfully.

Returns:

  • (Boolean)


61
# File 'lib/sevgi/function/shell.rb', line 61

def ok? = exit_code&.zero?

#outString

Returns captured stdout as a string.

Returns:



65
# File 'lib/sevgi/function/shell.rb', line 65

def out = outs.join("\n")

#outlineString?

Returns the first stdout line.

Returns:



69
# File 'lib/sevgi/function/shell.rb', line 69

def outline = outs.first