Class: ProgressBar::Components::Percentage

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-progressbar/components/percentage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Percentage

Returns a new instance of Percentage.



6
7
8
# File 'lib/ruby-progressbar/components/percentage.rb', line 6

def initialize(options = {})
  self.progress = options[:progress]
end

Instance Attribute Details

#progressObject

Returns the value of attribute progress.



4
5
6
# File 'lib/ruby-progressbar/components/percentage.rb', line 4

def progress
  @progress
end

Instance Method Details

#justified_percentageObject



14
15
16
# File 'lib/ruby-progressbar/components/percentage.rb', line 14

def justified_percentage
  progress.percentage_completed.to_s.rjust(3)
end

#justified_percentage_with_precisionObject



22
23
24
# File 'lib/ruby-progressbar/components/percentage.rb', line 22

def justified_percentage_with_precision
  progress.percentage_completed_with_precision.to_s.rjust(6)
end

#percentageObject



10
11
12
# File 'lib/ruby-progressbar/components/percentage.rb', line 10

def percentage
  progress.percentage_completed.to_s
end

#percentage_with_precisionObject



18
19
20
# File 'lib/ruby-progressbar/components/percentage.rb', line 18

def percentage_with_precision
  progress.percentage_completed_with_precision
end