Class: ProgressBar::Counter

Inherits:
Meter
  • Object
show all
Defined in:
lib/progress_bar/meters/counter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count, max) ⇒ Counter

Returns a new instance of Counter.



7
8
9
# File 'lib/progress_bar/meters/counter.rb', line 7

def initialize(count, max)
  @count, @max = count, max
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



5
6
7
# File 'lib/progress_bar/meters/counter.rb', line 5

def count
  @count
end

#maxObject (readonly)

Returns the value of attribute max.



5
6
7
# File 'lib/progress_bar/meters/counter.rb', line 5

def max
  @max
end

Instance Method Details

#max_counter_widthObject



19
20
21
# File 'lib/progress_bar/meters/counter.rb', line 19

def max_counter_width
  max.to_s.length
end

#to_sObject



11
12
13
# File 'lib/progress_bar/meters/counter.rb', line 11

def to_s
  "[%#{max_counter_width}i/%i]" % [count, max]
end

#widthObject



15
16
17
# File 'lib/progress_bar/meters/counter.rb', line 15

def width
  max.to_s.length * 2 + 3
end