Class: RPlusPlus::Command

Inherits:
Object
  • Object
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

.commandsObject



3
4
5
# File 'lib/rplusplus/command.rb', line 3

def self.commands
  @@commands ||= {}
end

.listObject



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