Class: Kommando::CommandResult::Failure

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ Failure

Returns a new instance of Failure.

Raises:

  • (ArgumentError)


44
45
46
47
48
49
# File 'lib/kommando/command_result.rb', line 44

def initialize(error)
  raise ArgumentError, 'missing `:error` key' unless error.key?(:error)
  raise ArgumentError, 'missing `:command` key' unless error.key?(:command)
  raise ArgumentError, 'missing `:parameters` key' unless error.key?(:parameters)
  @error = error
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



42
43
44
# File 'lib/kommando/command_result.rb', line 42

def error
  @error
end

Instance Method Details

#deconstruct_keys(_) ⇒ Object



63
64
65
# File 'lib/kommando/command_result.rb', line 63

def deconstruct_keys(_)
  { error: error }.merge(@error)
end

#error?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/kommando/command_result.rb', line 59

def error?
  true
end

#success?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/kommando/command_result.rb', line 55

def success?
  false
end

#valueObject

Raises:



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

def value
  raise NonExistentValue, 'Failure results do not have values'
end