Class: Yoda::Instrument::Progress

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/instrument.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length, &callback) ⇒ Progress

Returns a new instance of Progress.

Parameters:

  • length (Integer)
  • callback (#call)


43
44
45
46
47
48
# File 'lib/yoda/instrument.rb', line 43

def initialize(length, &callback)
  @length = length
  @index = 0
  @callback = callback
  call
end

Instance Attribute Details

#callback#call (readonly)

Returns:



39
40
41
# File 'lib/yoda/instrument.rb', line 39

def callback
  @callback
end

#indexInteger (readonly)

Returns:

  • (Integer)


36
37
38
# File 'lib/yoda/instrument.rb', line 36

def index
  @index
end

#lengthInteger (readonly)

Returns:

  • (Integer)


36
37
38
# File 'lib/yoda/instrument.rb', line 36

def length
  @length
end

Instance Method Details

#callObject



55
56
57
# File 'lib/yoda/instrument.rb', line 55

def call
  callback.call(length: length, index: index)
end

#incrementObject



50
51
52
53
# File 'lib/yoda/instrument.rb', line 50

def increment
  @index += 1
  call
end