Class: ExecutedShellCommand::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/executed_shell_command.rb

Overview

Immutable value object representing the outcome of a command execution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chdirObject

Returns the value of attribute chdir

Returns:

  • (Object)

    the current value of chdir



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def chdir
  @chdir
end

#commandObject

Returns the value of attribute command

Returns:

  • (Object)

    the current value of command



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def command
  @command
end

#envObject

Returns the value of attribute env

Returns:

  • (Object)

    the current value of env



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def env
  @env
end

#finished_atObject

Returns the value of attribute finished_at

Returns:

  • (Object)

    the current value of finished_at



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def finished_at
  @finished_at
end

#pidObject

Returns the value of attribute pid

Returns:

  • (Object)

    the current value of pid



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def pid
  @pid
end

#started_atObject

Returns the value of attribute started_at

Returns:

  • (Object)

    the current value of started_at



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def started_at
  @started_at
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def status
  @status
end

#stderrObject

Returns the value of attribute stderr

Returns:

  • (Object)

    the current value of stderr



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout

Returns:

  • (Object)

    the current value of stdout



35
36
37
# File 'lib/executed_shell_command.rb', line 35

def stdout
  @stdout
end

Instance Method Details

#durationObject



55
56
57
58
59
# File 'lib/executed_shell_command.rb', line 55

def duration
  return nil unless started_at && finished_at

  finished_at - started_at
end

#exit_codeObject



51
52
53
# File 'lib/executed_shell_command.rb', line 51

def exit_code
  status&.exitstatus
end

#signaled?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/executed_shell_command.rb', line 61

def signaled?
  status&.signaled?
end

#success?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/executed_shell_command.rb', line 47

def success?
  status&.success?
end

#termsigObject



65
66
67
# File 'lib/executed_shell_command.rb', line 65

def termsig
  status&.termsig
end

#to_hObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/executed_shell_command.rb', line 69

def to_h
  {
    command: command,
    stdout: stdout,
    stderr: stderr,
    exit_code: exit_code,
    success: success?,
    started_at: started_at,
    finished_at: finished_at,
    duration: duration,
    pid: pid,
    env: env,
    chdir: chdir,
    status: status
  }
end