Class: Falkor::Progress

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

Instance Method Summary collapse

Constructor Details

#initialize(total) ⇒ Progress

Returns a new instance of Progress.



5
6
7
8
9
# File 'lib/falkor/progress.rb', line 5

def initialize(total)
  @total = total
  @current = 0
  @previous = 0
end

Instance Method Details

#increment!(amount, description) {|percentage(current), description| ... } ⇒ Object

Yields:

  • (percentage(current), description)


11
12
13
14
15
16
17
# 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