Class: Botiasloop::Tools::Shell::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/botiasloop/tools/shell.rb

Overview

Result wrapper for shell execution

Instance Attribute Summary collapse

Instance Method Summary collapse

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_codeObject (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

#stderrObject (readonly)

Returns the value of attribute stderr.



28
29
30
# File 'lib/botiasloop/tools/shell.rb', line 28

def stderr
  @stderr
end

#stdoutObject (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

Returns:

  • (Boolean)


36
37
38
# File 'lib/botiasloop/tools/shell.rb', line 36

def success?
  @exit_code == 0
end

#to_hObject



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_sObject



40
41
42
# File 'lib/botiasloop/tools/shell.rb', line 40

def to_s
  "Exit: #{@exit_code}\nStdout:\n#{@stdout}\nStderr:\n#{@stderr}"
end