Class: Tataru::Taru
- Inherits:
-
Object
- Object
- Tataru::Taru
- Defined in:
- lib/tataru.rb
Overview
Entry class
Instance Method Summary collapse
- #error ⇒ Object
- #extract_state(key, value) ⇒ Object
-
#initialize(rtp, current_state = {}, &block) ⇒ Taru
constructor
A new instance of Taru.
- #oplog ⇒ Object
- #state ⇒ Object
- #step ⇒ Object
Constructor Details
#initialize(rtp, current_state = {}, &block) ⇒ Taru
Returns a new instance of Taru.
28 29 30 31 32 33 34 35 |
# 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 |
Instance Method Details
#error ⇒ Object
46 47 48 |
# File 'lib/tataru.rb', line 46 def error @runner.memory.error end |
#extract_state(key, value) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# 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 ⇒ Object
42 43 44 |
# File 'lib/tataru.rb', line 42 def oplog @runner.oplog end |
#state ⇒ Object
50 51 52 53 54 |
# 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 ⇒ Object
37 38 39 40 |
# File 'lib/tataru.rb', line 37 def step @runner.run_next !@runner.ended? end |