class Tataru::Taru

Entry class

Public Class Methods

new(rtp, current_state = {}, &block) click to toggle source
# File lib/tataru.rb, line 28
def initialize(rtp, current_state = {}, &block)
  @rtp = rtp
  @current_state = current_state
  @quest = Tataru::Quest.new(rtp, current_state)
  @quest.construct(&block)
  @ih = Tataru::InstructionHash.new(@quest.instr_hash)
  @runner = Tataru::Runner.new(@ih.instruction_list)
end

Public Instance Methods

error() click to toggle source
# File lib/tataru.rb, line 46
def error
  @runner.memory.error
end
extract_state(key, value) click to toggle source
# File lib/tataru.rb, line 56
def extract_state(key, value)
  if key.start_with? '_deletable_'
    original_key = key.sub(/^_deletable_/, '')
    [key, {
      name: value,
      desc: @current_state[original_key][:desc],
      dependencies: @current_state[original_key][:dependencies]
    }]
  else
    [key, {
      name: value,
      desc: @quest.dsl.resources[key].desc.class.name,
      dependencies: @quest.dsl.dep_graph[key]
    }]
  end
end
oplog() click to toggle source
# File lib/tataru.rb, line 42
def oplog
  @runner.oplog
end
state() click to toggle source
# File lib/tataru.rb, line 50
def state
  @runner.memory.hash[:remote_ids].map do |k, v|
    extract_state(k, v)
  end.to_h
end
step() click to toggle source
# File lib/tataru.rb, line 37
def step
  @runner.run_next
  !@runner.ended?
end