Class: BlocklyInterpreter::Interpreter
- Inherits:
-
Object
- Object
- BlocklyInterpreter::Interpreter
- Defined in:
- lib/blockly_interpreter/interpreter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#debug_messages ⇒ Object
readonly
Returns the value of attribute debug_messages.
-
#program ⇒ Object
readonly
Returns the value of attribute program.
Instance Method Summary collapse
- #add_debug_messages(debug_messages) ⇒ Object
- #build_execution_context ⇒ Object
- #execute ⇒ Object
-
#initialize(program) ⇒ Interpreter
constructor
A new instance of Interpreter.
Constructor Details
#initialize(program) ⇒ Interpreter
Returns a new instance of Interpreter.
6 7 8 9 |
# File 'lib/blockly_interpreter/interpreter.rb', line 6 def initialize(program) @program = program @debug_messages = [] end |
Instance Attribute Details
#debug_messages ⇒ Object (readonly)
Returns the value of attribute debug_messages.
4 5 6 |
# File 'lib/blockly_interpreter/interpreter.rb', line 4 def @debug_messages end |
#program ⇒ Object (readonly)
Returns the value of attribute program.
4 5 6 |
# File 'lib/blockly_interpreter/interpreter.rb', line 4 def program @program end |
Instance Method Details
#add_debug_messages(debug_messages) ⇒ Object
22 23 24 |
# File 'lib/blockly_interpreter/interpreter.rb', line 22 def () @debug_messages.push * end |
#build_execution_context ⇒ Object
11 12 13 |
# File 'lib/blockly_interpreter/interpreter.rb', line 11 def build_execution_context BlocklyInterpreter::ExecutionContext.new(self) end |
#execute ⇒ Object
15 16 17 18 19 20 |
# File 'lib/blockly_interpreter/interpreter.rb', line 15 def execute build_execution_context.tap do |context| context.execute(program.first_block) context. end end |