Class: Tataru::Quest

Inherits:
Object
  • Object
show all
Defined in:
lib/tataru/quest.rb

Overview

tataru

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pool, current_state = {}) ⇒ Quest

Returns a new instance of Quest.



8
9
10
11
12
# File 'lib/tataru/quest.rb', line 8

def initialize(pool, current_state = {})
  @pool = pool
  @current_state = current_state
  @dsl = TopDsl.new(pool)
end

Instance Attribute Details

#dslObject (readonly)

Returns the value of attribute dsl.



6
7
8
# File 'lib/tataru/quest.rb', line 6

def dsl
  @dsl
end

Instance Method Details

#construct(&block) ⇒ Object



14
15
16
# File 'lib/tataru/quest.rb', line 14

def construct(&block)
  @dsl.instance_eval(&block)
end

#extant_dependenciesObject



30
31
32
33
34
# File 'lib/tataru/quest.rb', line 30

def extant_dependencies
  @current_state.map do |resname, info|
    [resname, info[:dependencies]]
  end.to_h
end

#extant_resourcesObject



18
19
20
21
22
# File 'lib/tataru/quest.rb', line 18

def extant_resources
  @current_state.map do |resname, info|
    [resname, info[:desc]]
  end.to_h
end

#instr_hashObject



36
37
38
39
40
41
# File 'lib/tataru/quest.rb', line 36

def instr_hash
  c = Compiler.new(@dsl, extant_resources, extant_dependencies)
  result = c.instr_hash
  result[:init][:remote_ids] = remote_ids
  result
end

#remote_idsObject



24
25
26
27
28
# File 'lib/tataru/quest.rb', line 24

def remote_ids
  @current_state.map do |resname, info|
    [resname, info[:name]]
  end.to_h
end