class Yoda::Instrument::Progress

Attributes

callback[R]

@return [#call]

index[R]

@return [Integer]

length[R]

@return [Integer]

Public Class Methods

new(length, &callback) click to toggle source

@param length [Integer] @param callback [#call]

# File lib/yoda/instrument.rb, line 42
def initialize(length, &callback)
  @length = length
  @index = 0
  @callback = callback
  call
end

Public Instance Methods

call() click to toggle source
# File lib/yoda/instrument.rb, line 54
def call
  callback.call(length: length, index: index)
end
increment() click to toggle source
# File lib/yoda/instrument.rb, line 49
def increment
  @index += 1
  call
end