Class: Canoe::Stepper

Inherits:
Object
  • Object
show all
Defined in:
lib/util.rb

Overview

Stepper record the progress of a task progress is obtained via #‘progress_as_str

Instance Method Summary collapse

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_strObject



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

#stepObject



21
22
23
# File 'lib/util.rb', line 21

def step
  @togo -= 1 if @togo.positive?
end