11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/nmg/type/maintenance.rb', line 11
def self.generate(count, options = {}, generator = Random.new)
options = {from: 1, to: 20, step: {min: 10, max: 50}}.merge(options)
arr = []
duration = (options[:from]..options[:to])
step = (options[:step][:min]..options[:step][:max])
arr << Maintenance.new(start: generator.rand(step),
duration: generator.rand(duration))
count.to_i.times do
last = arr.last
arr << Maintenance.new(start: last.stop + generator.rand(step),
duration: generator.rand(duration))
end
arr
end
|