Class: Xezat::CommandManager

Inherits:
Object
  • Object
show all
Defined in:
lib/xezat/commands.rb

Overview

command を管理するクラス

Constant Summary collapse

@@commands =
{}

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



27
28
29
# File 'lib/xezat/commands.rb', line 27

def self.[](name)
  @@commands[name]
end

.load_default_commands(path = File::expand_path(File::join(File::dirname(__FILE__), 'command'))) ⇒ Object

command をロードする



17
18
19
20
21
# File 'lib/xezat/commands.rb', line 17

def self.load_default_commands(path = File::expand_path(File::join(File::dirname(__FILE__), 'command')))
  Dir::glob(File::join(path, '*.rb')) do |rb|
    require rb
  end
end

.program=(program) ⇒ Object



23
24
25
# File 'lib/xezat/commands.rb', line 23

def self.program=(program)
  @@program = program
end

.register(name, klass) ⇒ Object

command を登録する



11
12
13
14
# File 'lib/xezat/commands.rb', line 11

def self.register(name, klass)
  raise MultipleCommandDefinitionError, "'#{name}' already defined" if @@commands.key?(name)
  @@commands[name] = klass.new(@@program)
end