Method: Commandant::Command#initialize
- Defined in:
- lib/commandant/command.rb
#initialize(name, description = nil, &command) ⇒ Command
Create a new command by name and add it to the commands list.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/commandant/command.rb', line 11 def initialize(name, description=nil, &command) raise ArgumentError, "Must provide a command block" unless command raise ArgumentError, "Command already exists: #{name}" if COMMANDS[name] @name = name @description = description @command = command COMMANDS[@name] = self end |