Class: TheDude::Dsl
- Inherits:
-
Object
- Object
- TheDude::Dsl
- Defined in:
- lib/the_dude/dsl.rb
Class Method Summary collapse
-
.from_file(path) ⇒ Object
Reads in a file and processes it using The Dude Dsl.
-
.run(text = nil, &code) ⇒ Object
Runs the specified code inside an instance of the DSL.
Instance Method Summary collapse
-
#ask(*args) ⇒ Object
Forwards the call on to ask.
-
#command(*args, &block) ⇒ Object
Forwards the call on to Command.new.
-
#say(*args) ⇒ Object
Forwards the call on to say.
-
#var(*args) ⇒ Object
Creates and registers a new variable.
Class Method Details
.from_file(path) ⇒ Object
Reads in a file and processes it using The Dude Dsl
42 43 44 |
# File 'lib/the_dude/dsl.rb', line 42 def from_file path run File.read(path) if File.exists? path end |
.run(text = nil, &code) ⇒ Object
Runs the specified code inside an instance of the DSL. Code can be passed as a string or block. If both are given, the string is ignored.
31 32 33 34 35 36 37 |
# File 'lib/the_dude/dsl.rb', line 31 def run text=nil, &code if block_given? new.instance_exec &code else new.instance_eval text end end |
Instance Method Details
#ask(*args) ⇒ Object
Forwards the call on to TheDude.ask
4 5 6 |
# File 'lib/the_dude/dsl.rb', line 4 def ask *args TheDude.ask *args end |
#command(*args, &block) ⇒ Object
Forwards the call on to Command.new
9 10 11 |
# File 'lib/the_dude/dsl.rb', line 9 def command *args, &block TheDude::Command.new *args, &block end |
#say(*args) ⇒ Object
Forwards the call on to TheDude.say
14 15 16 |
# File 'lib/the_dude/dsl.rb', line 14 def say *args TheDude.say *args end |