Module: StallmanBot::Commands

Defined in:
lib/stallman_bot/commands.rb,
lib/stallman_bot/commands/base.rb,
lib/stallman_bot/commands/stop.rb,
lib/stallman_bot/commands/start.rb,
lib/stallman_bot/commands/status.rb

Defined Under Namespace

Classes: Base, Start, Status, Stop

Class Method Summary collapse

Class Method Details

.allObject



20
21
22
# File 'lib/stallman_bot/commands.rb', line 20

def self.all
  @all ||= commands
end

.commandsObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/stallman_bot/commands.rb', line 7

def self.commands
  path = File.join(File.dirname(__FILE__), 'commands')
  files = Dir.entries(path).select { |f| f.include?('.rb') }
  commands = {}
  files.each do |f|
    name = f[0..-4]
    method = "StallmanBot::Commands::#{name.capitalize}"
    commands["/#{name}"] = method
    commands["/#{name}@#{StallmanBot.config[:name]}"] = method
  end
  commands.reject { |k, _| k.include? 'base' }
end