Class: Knife::Pkg::ShellCommandResult

Inherits:
Object
  • Object
show all
Defined in:
lib/knife-pkg/shell_command_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd, stdout, stderr, exit_code) ⇒ ShellCommandResult

Returns a new instance of ShellCommandResult.



26
27
28
29
30
31
# File 'lib/knife-pkg/shell_command_result.rb', line 26

def initialize(cmd, stdout, stderr, exit_code)
  @cmd = cmd
  @stdout = stdout
  @stderr = stderr
  @exit_code = exit_code
end

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd.



21
22
23
# File 'lib/knife-pkg/shell_command_result.rb', line 21

def cmd
  @cmd
end

#exit_codeObject

Returns the value of attribute exit_code.



24
25
26
# File 'lib/knife-pkg/shell_command_result.rb', line 24

def exit_code
  @exit_code
end

#stderrObject

Returns the value of attribute stderr.



23
24
25
# File 'lib/knife-pkg/shell_command_result.rb', line 23

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout.



22
23
24
# File 'lib/knife-pkg/shell_command_result.rb', line 22

def stdout
  @stdout
end

Instance Method Details

#succeeded?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/knife-pkg/shell_command_result.rb', line 37

def succeeded?
  return @exit_code.to_i == 0 ? true : false
end

#to_sObject



33
34
35
# File 'lib/knife-pkg/shell_command_result.rb', line 33

def to_s
  return "Command: \"#{@cmd}\", stdout: \"#{@stdout}\", stderr: \"#{@stderr}\", exit_code: \"#{@exit_code}\""
end