Class: FBomb::Command::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/fbomb/command.rb

Overview

dsl

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDSL

Returns a new instance of DSL.



151
152
153
# File 'lib/fbomb/command.rb', line 151

def initialize
  @commands = Command.table
end

Class Method Details

.evaluate(*args, &block) ⇒ Object



145
146
147
148
149
# File 'lib/fbomb/command.rb', line 145

def DSL.evaluate(*args, &block)
  dsl = new
  dsl.evaluate(*args, &block)
  dsl
end

Instance Method Details

#call(&block) ⇒ Object



176
177
178
# File 'lib/fbomb/command.rb', line 176

def call(&block)
  @command.call = block
end

#command(*args, &block) ⇒ Object Also known as: Command



159
160
161
162
163
164
165
# File 'lib/fbomb/command.rb', line 159

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

#evaluate(*args, &block) ⇒ Object



155
156
157
# File 'lib/fbomb/command.rb', line 155

def evaluate(*args, &block)
  Object.instance_method(:instance_eval).bind(self).call(&block)
end

#help(*args) ⇒ Object



168
169
170
# File 'lib/fbomb/command.rb', line 168

def help(*args)
  @command.help = args.join("\n")
end

#setup(&block) ⇒ Object



172
173
174
# File 'lib/fbomb/command.rb', line 172

def setup(&block)
  @command.setup = block
end