Class: Kommando::CommandResult::Success

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Success

Returns a new instance of Success.

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/kommando/command_result.rb', line 18

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



16
17
18
# File 'lib/kommando/command_result.rb', line 16

def value
  @value
end

Instance Method Details

#deconstruct_keys(_) ⇒ Object



36
37
38
# File 'lib/kommando/command_result.rb', line 36

def deconstruct_keys(_)
  { value: @value[:command] }.merge(@value)
end

#errorObject

Raises:



24
25
26
# File 'lib/kommando/command_result.rb', line 24

def error
  raise NonExistentError, 'Success results do not have errors'
end

#error?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/kommando/command_result.rb', line 32

def error?
  false
end

#success?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/kommando/command_result.rb', line 28

def success?
  true
end