class Falkor::Progress
Attributes
current[RW]
previous[RW]
total[R]
Public Class Methods
new(total)
click to toggle source
# File lib/falkor/progress.rb, line 5 def initialize(total) @total = total @current = 0 @previous = 0 end
Public Instance Methods
increment!(amount, description) { |percentage(current), description| ... }
click to toggle source
# File lib/falkor/progress.rb, line 11 def increment!(amount, description) self.previous, self.current = current, current + amount return if percentage(previous) == percentage(current) && !description yield percentage(current), description end
Private Instance Methods
percentage(amount)
click to toggle source
# File lib/falkor/progress.rb, line 24 def percentage(amount) (amount.to_f / total * 100).to_i end