Class: Tataru::Instructions::CheckInstruction

Inherits:
ResourceInstruction show all
Defined in:
lib/tataru/instructions/check_instruction.rb

Overview

General checking class

Instance Attribute Summary

Attributes inherited from Tataru::Instruction

#memory

Instance Method Summary collapse

Methods inherited from ResourceInstruction

#desc

Methods inherited from Tataru::Instruction

#execute, expects

Constructor Details

#initialize(check_type) ⇒ CheckInstruction

Returns a new instance of CheckInstruction.



7
8
9
# File 'lib/tataru/instructions/check_instruction.rb', line 7

def initialize(check_type)
  @check_type = check_type
end

Instance Method Details

#after_complete(_memory) ⇒ Object



23
# File 'lib/tataru/instructions/check_instruction.rb', line 23

def after_complete(_memory); end

#runObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tataru/instructions/check_instruction.rb', line 11

def run
  resource_class = desc.resource_class
  resource = resource_class.new(memory.hash[:remote_ids][resource_name])

  if resource.send(:"#{@check_type}_complete?")
    after_complete
  else
    # repeat this instruction until its done
    memory.program_counter -= 1
  end
end