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.
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)
38 39 40 |
# File 'lib/yoda/instrument.rb', line 38 def callback @callback end |
#index ⇒ Integer (readonly)
35 36 37 |
# File 'lib/yoda/instrument.rb', line 35 def index @index end |
#length ⇒ Integer (readonly)
35 36 37 |
# File 'lib/yoda/instrument.rb', line 35 def length @length end |
Instance Method Details
#call ⇒ Object
54 55 56 |
# File 'lib/yoda/instrument.rb', line 54 def call callback.call(length: length, index: index) end |
#increment ⇒ Object
49 50 51 52 |
# File 'lib/yoda/instrument.rb', line 49 def increment @index += 1 call end |