Class: Spinebox::Command::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/spinebox/command.rb

Overview

Encapsules a registered command

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, desc, options, &block) ⇒ Command

Returns a new instance of Command.



59
60
61
# File 'lib/spinebox/command.rb', line 59

def initialize command, desc, options, &block
  @command, @desc, @options, @block = command, desc, options, block
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



55
56
57
# File 'lib/spinebox/command.rb', line 55

def command
  @command
end

#descObject (readonly)

Returns the value of attribute desc.



56
57
58
# File 'lib/spinebox/command.rb', line 56

def desc
  @desc
end

#optionsObject (readonly)

Returns the value of attribute options.



57
58
59
# File 'lib/spinebox/command.rb', line 57

def options
  @options
end

Instance Method Details

#run!Object



63
64
65
66
67
# File 'lib/spinebox/command.rb', line 63

def run!
  return false unless @options[:if].call
  @block.call
  true
end