Class: OsCtl::Lib::SystemCommandResult

Inherits:
Object
  • Object
show all
Defined in:
lib/libosctl/system_command_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exitstatus, output) ⇒ SystemCommandResult

Returns a new instance of SystemCommandResult.

Parameters:

  • exitstatus (Integer)
  • output (String)


11
12
13
14
# File 'lib/libosctl/system_command_result.rb', line 11

def initialize(exitstatus, output)
  @exitstatus = exitstatus
  @output = output
end

Instance Attribute Details

#exitstatusInteger (readonly)

Returns:

  • (Integer)


4
5
6
# File 'lib/libosctl/system_command_result.rb', line 4

def exitstatus
  @exitstatus
end

#outputString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/libosctl/system_command_result.rb', line 7

def output
  @output
end

Instance Method Details

#[](key) ⇒ Object



24
25
26
27
28
29
# File 'lib/libosctl/system_command_result.rb', line 24

def [](key)
  warn "Accessing command result using [#{key}] is deprecated"
  warn 'Caller backtrace:'
  warn caller.join("\n")
  send(key)
end

#error?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/libosctl/system_command_result.rb', line 20

def error?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/libosctl/system_command_result.rb', line 16

def success?
  exitstatus == 0
end