Class: ProgressBar::Percentage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count, max) ⇒ Percentage

Returns a new instance of Percentage.



7
8
9
# File 'lib/progress_bar/meters/percentage.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/percentage.rb', line 5

def count
  @count
end

#maxObject (readonly)

Returns the value of attribute max.



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

def max
  @max
end

Instance Method Details

#to_sObject



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

def to_s
  "[%6.2f%%]" % (count.to_f / max * 100)
end

#widthObject



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

def width
  9
end