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)


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

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

Instance Attribute Details

#callback#call (readonly)

Returns:



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

def callback
  @callback
end

#indexInteger (readonly)

Returns:

  • (Integer)


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

def index
  @index
end

#lengthInteger (readonly)

Returns:

  • (Integer)


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

def length
  @length
end

Instance Method Details

#callObject



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

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

#incrementObject



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

def increment
  @index += 1
  call
end