Class: WifiWand::CommandExecutor::OsCommandResult

Inherits:
Object
  • Object
show all
Defined in:
lib/wifi_wand/services/command_executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, stderr:, combined_output:, exitstatus:, command:, duration:, termsig: nil) ⇒ OsCommandResult

Returns a new instance of OsCommandResult.



324
325
326
327
328
329
330
331
332
# File 'lib/wifi_wand/services/command_executor.rb', line 324

def initialize(stdout:, stderr:, combined_output:, exitstatus:, command:, duration:, termsig: nil)
  @stdout = stdout || ''
  @stderr = stderr || ''
  @combined_output = combined_output || ''
  @exitstatus = exitstatus
  @termsig = termsig
  @command = command
  @duration = duration
end

Instance Attribute Details

#combined_outputObject (readonly)

Returns the value of attribute combined_output.



322
323
324
# File 'lib/wifi_wand/services/command_executor.rb', line 322

def combined_output
  @combined_output
end

#commandObject (readonly)

Returns the value of attribute command.



322
323
324
# File 'lib/wifi_wand/services/command_executor.rb', line 322

def command
  @command
end

#durationObject (readonly)

Returns the value of attribute duration.



322
323
324
# File 'lib/wifi_wand/services/command_executor.rb', line 322

def duration
  @duration
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



322
323
324
# File 'lib/wifi_wand/services/command_executor.rb', line 322

def exitstatus
  @exitstatus
end

#stderrObject (readonly)

Returns the value of attribute stderr.



322
323
324
# File 'lib/wifi_wand/services/command_executor.rb', line 322

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



322
323
324
# File 'lib/wifi_wand/services/command_executor.rb', line 322

def stdout
  @stdout
end

#termsigObject (readonly)

Returns the value of attribute termsig.



322
323
324
# File 'lib/wifi_wand/services/command_executor.rb', line 322

def termsig
  @termsig
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


334
# File 'lib/wifi_wand/services/command_executor.rb', line 334

def success? = termsig.nil? && exitstatus == 0

#termination_statusObject



338
339
340
341
342
343
344
# File 'lib/wifi_wand/services/command_executor.rb', line 338

def termination_status
  if termsig
    "Signal: #{signal_label(termsig)}"
  else
    "Exit code: #{exitstatus || 'unknown'}"
  end
end

#to_hObject



346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/wifi_wand/services/command_executor.rb', line 346

def to_h
  data = {
    stdout:          stdout,
    stderr:          stderr,
    combined_output: combined_output,
    exitstatus:      exitstatus,
    command:         command,
    duration:        duration,
  }
  data[:termsig] = termsig if termsig
  data
end

#to_sObject



336
# File 'lib/wifi_wand/services/command_executor.rb', line 336

def to_s = combined_output