Class: Yoda::Instrument::Progress
- Inherits:
-
Object
- Object
- Yoda::Instrument::Progress
- Defined in:
- lib/yoda/instrument.rb
Instance Attribute Summary collapse
- #callback ⇒ #call readonly
- #index ⇒ Integer readonly
- #length ⇒ Integer readonly
Instance Method Summary collapse
- #call ⇒ Object
- #increment ⇒ Object
-
#initialize(length, &callback) ⇒ Progress
constructor
A new instance of Progress.
Constructor Details
#initialize(length, &callback) ⇒ Progress
Returns a new instance of Progress.
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)
39 40 41 |
# File 'lib/yoda/instrument.rb', line 39 def callback @callback end |
#index ⇒ Integer (readonly)
36 37 38 |
# File 'lib/yoda/instrument.rb', line 36 def index @index end |
#length ⇒ Integer (readonly)
36 37 38 |
# File 'lib/yoda/instrument.rb', line 36 def length @length end |
Instance Method Details
#call ⇒ Object
55 56 57 |
# File 'lib/yoda/instrument.rb', line 55 def call callback.call(length: length, index: index) end |
#increment ⇒ Object
50 51 52 53 |
# File 'lib/yoda/instrument.rb', line 50 def increment @index += 1 call end |