class FBomb::Command::DSL

dsl

Public Class Methods

evaluate(*args, &block) click to toggle source
# File lib/fbomb/command.rb, line 151
def DSL.evaluate(*args, &block)
  dsl = new
  dsl.evaluate(*args, &block)
  dsl
end
new() click to toggle source
# File lib/fbomb/command.rb, line 157
def initialize
  @commands = Command.table
end

Public Instance Methods

Command(*args, &block)
Alias for: command
call(&block) click to toggle source
# File lib/fbomb/command.rb, line 199
def call(&block)
  @command.call = block
end
command(*args, &block) click to toggle source
# File lib/fbomb/command.rb, line 165
def command(*args, &block)
  return @command if(args.empty? and block.nil?)
  @command = Command.new
  @command.key = Util.absolute_key_for(args.shift)
  @commands[@command.key] ||= @command
  evaluate(&block)
end
Also aliased as: Command
evaluate(*args, &block) click to toggle source
# File lib/fbomb/command.rb, line 161
def evaluate(*args, &block)
  Object.instance_method(:instance_eval).bind(self).call(&block)
end
help(*args) click to toggle source
# File lib/fbomb/command.rb, line 191
def help(*args)
  @command.help = args.join("\n")
end
match(*args, &block) click to toggle source
# File lib/fbomb/command.rb, line 174
def match(*args, &block)
  return @command if(args.empty? and block.nil?)
  @command = Command.new
  pattern = args.shift
  key = Util.absolute_key_for(pattern.to_s)
  @command.key = key
  @command.patterns.push(pattern)
  @commands[@command.key] ||= @command
  evaluate(&block)
end
matches(*args) click to toggle source
# File lib/fbomb/command.rb, line 185
def matches(*args)
  args.each do |arg|
    @command.patterns.push(arg)
  end
end
setup(&block) click to toggle source
# File lib/fbomb/command.rb, line 195
def setup(&block)
  @command.setup = block
end