Class: RPlusPlus::Command
- Inherits:
-
Object
- Object
- RPlusPlus::Command
show all
- Defined in:
- lib/rplusplus/command.rb
Defined Under Namespace
Classes: MissingCommandError
Class Method Summary
collapse
Class Method Details
.call(name, *args) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/rplusplus/command.rb', line 15
def self.call name, *args
name = name.to_sym
if !self.commands.has_key? name
raise MissingCommandError.new("'#{name}' is not a r++ command")
end
self.commands[name].call(*args)
end
|
.commands ⇒ Object
3
4
5
|
# File 'lib/rplusplus/command.rb', line 3
def self.commands
@@commands ||= {}
end
|
.list ⇒ Object
11
12
13
|
# File 'lib/rplusplus/command.rb', line 11
def self.list
self.commands.keys
end
|
.register(name, command) ⇒ Object
7
8
9
|
# File 'lib/rplusplus/command.rb', line 7
def self.register name, command
self.commands[name] = command
end
|