Class: Tataru::Instruction
- Inherits:
-
Object
- Object
- Tataru::Instruction
- Defined in:
- lib/tataru/instruction.rb
Overview
a thing to do
Direct Known Subclasses
Tataru::Instructions::ClearInstruction, Tataru::Instructions::EndInstruction, Tataru::Instructions::ImmediateModeInstruction, Tataru::Instructions::InitInstruction, Tataru::Instructions::ResourceInstruction, Tataru::Instructions::ReturnInstruction
Class Attribute Summary collapse
-
.expected_params ⇒ Object
Returns the value of attribute expected_params.
Instance Attribute Summary collapse
-
#memory ⇒ Object
Returns the value of attribute memory.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.expected_params ⇒ Object
Returns the value of attribute expected_params.
7 8 9 |
# File 'lib/tataru/instruction.rb', line 7 def expected_params @expected_params end |
Instance Attribute Details
#memory ⇒ Object
Returns the value of attribute memory.
21 22 23 |
# File 'lib/tataru/instruction.rb', line 21 def memory @memory end |
Class Method Details
.expects(symbol) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tataru/instruction.rb', line 9 def expects(symbol) @expected_params ||= [] @expected_params << symbol define_method symbol do return nil if @memory&.hash.nil? memory.hash[:temp][symbol] end end |
Instance Method Details
#execute(memory) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tataru/instruction.rb', line 23 def execute(memory) @memory = memory self.class.expected_params&.each do |symbol| unless memory.hash[:temp].key? symbol raise "required param #{symbol} not found" end end run end |
#run ⇒ Object
34 |
# File 'lib/tataru/instruction.rb', line 34 def run; end |