Class: Bonito::Distribution

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bonito/serial_timeline.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(start, serial, stretch: 1) ⇒ Distribution

Returns a new instance of Distribution.



302
303
304
305
306
# File 'lib/bonito/serial_timeline.rb', line 302

def initialize(start, serial, stretch: 1)
  @start = start
  @serial = serial
  @stretch = stretch
end

Instance Method Details

#eachObject



308
309
310
311
312
313
314
# File 'lib/bonito/serial_timeline.rb', line 308

def each
  @serial.zip(generate_offsets).reduce(0) do |consumed, zipped|
    timeline, offset = zipped
    yield timeline, @start + (@stretch * (offset + consumed))
    consumed + timeline.duration
  end
end