Class: FBomb::Command::DSL
- Inherits:
-
Object
- Object
- FBomb::Command::DSL
- Defined in:
- lib/fbomb/command.rb
Overview
dsl
Class Method Summary collapse
Instance Method Summary collapse
- #call(&block) ⇒ Object
- #command(*args, &block) ⇒ Object (also: #Command)
- #evaluate(*args, &block) ⇒ Object
- #help(*args) ⇒ Object
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
- #setup(&block) ⇒ Object
Constructor Details
#initialize ⇒ DSL
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 |