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)


40
41
42
43
44
45
# File 'lib/yoda/instrument.rb', line 40

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

Instance Attribute Details

#callback#call (readonly)

Returns:



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

def callback
  @callback
end

#indexInteger (readonly)

Returns:

  • (Integer)


33
34
35
# File 'lib/yoda/instrument.rb', line 33

def index
  @index
end

#lengthInteger (readonly)

Returns:

  • (Integer)


33
34
35
# File 'lib/yoda/instrument.rb', line 33

def length
  @length
end

Instance Method Details

#callObject



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

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

#incrementObject



47
48
49
50
# File 'lib/yoda/instrument.rb', line 47

def increment
  @index += 1
  call
end