Class: SmartBox::CommandResult

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_box/command_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command:, cwd:, stdout:, stderr:, exit_code:, started_at:, ended_at:) ⇒ CommandResult

Returns a new instance of CommandResult.



7
8
9
10
11
12
13
14
15
# File 'lib/smart_box/command_result.rb', line 7

def initialize(command:, cwd:, stdout:, stderr:, exit_code:, started_at:, ended_at:)
  @command    = command
  @cwd        = cwd
  @stdout     = stdout
  @stderr     = stderr
  @exit_code  = exit_code
  @started_at = started_at
  @ended_at   = ended_at
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/smart_box/command_result.rb', line 5

def command
  @command
end

#cwdObject (readonly)

Returns the value of attribute cwd.



5
6
7
# File 'lib/smart_box/command_result.rb', line 5

def cwd
  @cwd
end

#ended_atObject (readonly)

Returns the value of attribute ended_at.



5
6
7
# File 'lib/smart_box/command_result.rb', line 5

def ended_at
  @ended_at
end

#exit_codeObject (readonly)

Returns the value of attribute exit_code.



5
6
7
# File 'lib/smart_box/command_result.rb', line 5

def exit_code
  @exit_code
end

#started_atObject (readonly)

Returns the value of attribute started_at.



5
6
7
# File 'lib/smart_box/command_result.rb', line 5

def started_at
  @started_at
end

#stderrObject (readonly)

Returns the value of attribute stderr.



5
6
7
# File 'lib/smart_box/command_result.rb', line 5

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



5
6
7
# File 'lib/smart_box/command_result.rb', line 5

def stdout
  @stdout
end

Instance Method Details

#elapsed_msObject



21
22
23
# File 'lib/smart_box/command_result.rb', line 21

def elapsed_ms
  ((@ended_at - @started_at) * 1000).to_i
end

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/smart_box/command_result.rb', line 17

def success?
  @exit_code == 0
end