Class: Rant::ProgressCountdown
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #inc ⇒ Object
-
#initialize(total, rant = nil) ⇒ ProgressCountdown
constructor
A new instance of ProgressCountdown.
Constructor Details
#initialize(total, rant = nil) ⇒ ProgressCountdown
Returns a new instance of ProgressCountdown.
9 10 11 12 13 14 15 |
# File 'lib/rant/progress.rb', line 9 def initialize(total, rant=nil) @total = total @step = @total / 10 @fraction = 10 @rant = rant @current = 0 end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
8 9 10 |
# File 'lib/rant/progress.rb', line 8 def current @current end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
8 9 10 |
# File 'lib/rant/progress.rb', line 8 def total @total end |
Instance Method Details
#inc ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rant/progress.rb', line 16 def inc @current += 1 if @step > 0 and @current % @step == 0 @fraction -= 1 print_progress "#@fraction " if @fraction >= 0 end end |