class Tataru::Instruction

a thing to do

Attributes

expected_params[RW]
memory[RW]

Public Class Methods

expects(symbol) click to toggle source
# 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

Public Instance Methods

execute(memory) click to toggle source
# 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() click to toggle source
# File lib/tataru/instruction.rb, line 34
def run; end