Class: Rant::ProgressCountdown

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#currentObject (readonly)

Returns the value of attribute current.



8
9
10
# File 'lib/rant/progress.rb', line 8

def current
  @current
end

#totalObject (readonly)

Returns the value of attribute total.



8
9
10
# File 'lib/rant/progress.rb', line 8

def total
  @total
end

Instance Method Details

#incObject



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