Class: Dogfood::StoryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dogfood/story_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(pack:, rng:) ⇒ StoryBuilder

Returns a new instance of StoryBuilder.



5
6
7
8
9
# File 'lib/dogfood/story_builder.rb', line 5

def initialize(pack:, rng:)
  @pack = pack
  @rng = rng
  @counter = 0
end

Instance Method Details

#available_keysObject



19
20
21
# File 'lib/dogfood/story_builder.rb', line 19

def available_keys
  @pack.scenario_keys
end

#build(fleet_ratio: 0.0, include: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/dogfood/story_builder.rb', line 11

def build(fleet_ratio: 0.0, include: nil)
  @counter += 1
  id = "WO-#{@counter.to_s.rjust(3, '0')}"
  name = include || @pack.scenario_keys.sample(random: @rng)
  klass = @pack.find_scenario(name)
  klass.new(rng: @rng, id: id)
end