Class: Canoe::Stepper
- Inherits:
-
Object
- Object
- Canoe::Stepper
- Defined in:
- lib/util.rb
Overview
Stepper record the progress of a task progress is obtained via #‘progress_as_str
Instance Method Summary collapse
-
#initialize(total, togo) ⇒ Stepper
constructor
A new instance of Stepper.
- #progress_as_str ⇒ Object
- #step ⇒ Object
Constructor Details
#initialize(total, togo) ⇒ Stepper
Returns a new instance of Stepper.
11 12 13 14 |
# File 'lib/util.rb', line 11 def initialize(total, togo) @total = total.to_f @togo = togo.to_f end |
Instance Method Details
#progress_as_str ⇒ Object
16 17 18 19 |
# File 'lib/util.rb', line 16 def progress_as_str progress = ((@total - @togo) / @total).round(2) * 100 "[#{progress.to_i}%%]" end |
#step ⇒ Object
21 22 23 |
# File 'lib/util.rb', line 21 def step @togo -= 1 if @togo.positive? end |