Class: ProgressBar::Components::Bar
- Inherits:
-
Object
- Object
- ProgressBar::Components::Bar
- Includes:
- Progressable
- Defined in:
- lib/progress_bar/components/bar.rb
Constant Summary collapse
- DEFAULT_PROGRESS_MARK =
'='
Constants included from Progressable
Progressable::DEFAULT_BEGINNING_POSITION, Progressable::DEFAULT_SMOOTHING, Progressable::DEFAULT_TOTAL
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#progress_mark ⇒ Object
Returns the value of attribute progress_mark.
Attributes included from Progressable
#progress, #running_average, #smoothing, #starting_position, #total
Instance Method Summary collapse
- #empty_string ⇒ Object
-
#initialize(options = {}) ⇒ Bar
constructor
A new instance of Bar.
- #integrated_percentage_complete_string ⇒ Object
- #standard_complete_string ⇒ Object
- #to_s(options = {:format => :standard}) ⇒ Object
Methods included from Progressable
#decrement, #finish, #increment, #percentage_completed, #percentage_completed_with_precision, #reset, #start, #started?
Constructor Details
#initialize(options = {}) ⇒ Bar
Returns a new instance of Bar.
11 12 13 14 15 |
# File 'lib/progress_bar/components/bar.rb', line 11 def initialize( = {}) super self.progress_mark = [:progress_mark] || DEFAULT_PROGRESS_MARK end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
9 10 11 |
# File 'lib/progress_bar/components/bar.rb', line 9 def length @length end |
#progress_mark ⇒ Object
Returns the value of attribute progress_mark.
8 9 10 |
# File 'lib/progress_bar/components/bar.rb', line 8 def progress_mark @progress_mark end |
Instance Method Details
#empty_string ⇒ Object
34 35 36 |
# File 'lib/progress_bar/components/bar.rb', line 34 def empty_string ' ' * (length - completed_length) end |
#integrated_percentage_complete_string ⇒ Object
24 25 26 27 28 |
# File 'lib/progress_bar/components/bar.rb', line 24 def integrated_percentage_complete_string return standard_complete_string if completed_length < 5 " #{percentage_completed} ".to_s.center(completed_length, progress_mark) end |
#standard_complete_string ⇒ Object
30 31 32 |
# File 'lib/progress_bar/components/bar.rb', line 30 def standard_complete_string progress_mark * completed_length end |
#to_s(options = {:format => :standard}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/progress_bar/components/bar.rb', line 17 def to_s( = {:format => :standard}) completed_string = send(:"#{[:format]}_complete_string") empty_string = ' ' * (length - completed_string.length) "#{completed_string}#{empty_string}" end |