Class: NaturalDSL::CommandRunner
- Inherits:
-
Object
- Object
- NaturalDSL::CommandRunner
- Defined in:
- lib/natural_dsl/command_runner.rb
Defined Under Namespace
Classes: StackNotEmpty
Instance Method Summary collapse
-
#initialize(command, vm) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
- #run ⇒ Object
Constructor Details
#initialize(command, vm) ⇒ CommandRunner
Returns a new instance of CommandRunner.
9 10 11 12 |
# File 'lib/natural_dsl/command_runner.rb', line 9 def initialize(command, vm) @command = command @vm = vm end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/natural_dsl/command_runner.rb', line 14 def run args = @command.expectations.flat_map do |expectation| expectation.read_arguments(@vm.stack) end raise_stack_not_empty_error if @vm.stack.any? @command.execution_block.call(@vm, *args) end |