module StallmanBot::Commands

Public Class Methods

all() click to toggle source
# File lib/stallman_bot/commands.rb, line 20
def self.all
  @all ||= commands
end

Private Class Methods

commands() click to toggle source
# 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