Class: ProgressBar::Components::Bar
- Inherits:
-
Object
- Object
- ProgressBar::Components::Bar
- Defined in:
- lib/ruby-progressbar/components/bar.rb
Constant Summary collapse
- DEFAULT_PROGRESS_MARK =
'='.freeze
- DEFAULT_REMAINDER_MARK =
' '.freeze
- DEFAULT_UPA_STEPS =
['=---', '-=--', '--=-', '---='].freeze
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#progress_mark ⇒ Object
Returns the value of attribute progress_mark.
-
#remainder_mark ⇒ Object
Returns the value of attribute remainder_mark.
-
#upa_steps ⇒ Object
Returns the value of attribute upa_steps.
Instance Method Summary collapse
- #bar(length) ⇒ Object
- #bar_with_percentage(length) ⇒ Object
- #complete_bar(length) ⇒ Object
- #complete_bar_with_percentage(length) ⇒ Object
- #incomplete_space(length) ⇒ Object
-
#initialize(options = {}) ⇒ Bar
constructor
A new instance of Bar.
- #to_s(options = { :format => :standard }) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Bar
Returns a new instance of Bar.
17 18 19 20 21 22 23 |
# File 'lib/ruby-progressbar/components/bar.rb', line 17 def initialize( = {}) self.upa_steps = [:unknown_progress_animation_steps] || DEFAULT_UPA_STEPS self.progress_mark = [:progress_mark] || DEFAULT_PROGRESS_MARK self.remainder_mark = [:remainder_mark] || DEFAULT_REMAINDER_MARK self.progress = [:progress] self.length = [:length] end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
11 12 13 |
# File 'lib/ruby-progressbar/components/bar.rb', line 11 def length @length end |
#progress ⇒ Object
Returns the value of attribute progress.
11 12 13 |
# File 'lib/ruby-progressbar/components/bar.rb', line 11 def progress @progress end |
#progress_mark ⇒ Object
Returns the value of attribute progress_mark.
11 12 13 |
# File 'lib/ruby-progressbar/components/bar.rb', line 11 def progress_mark @progress_mark end |
#remainder_mark ⇒ Object
Returns the value of attribute remainder_mark.
11 12 13 |
# File 'lib/ruby-progressbar/components/bar.rb', line 11 def remainder_mark @remainder_mark end |
#upa_steps ⇒ Object
Returns the value of attribute upa_steps.
11 12 13 |
# File 'lib/ruby-progressbar/components/bar.rb', line 11 def upa_steps @upa_steps end |
Instance Method Details
#bar(length) ⇒ Object
35 36 37 38 39 |
# File 'lib/ruby-progressbar/components/bar.rb', line 35 def (length) self.length = length standard_complete_string end |
#bar_with_percentage(length) ⇒ Object
63 64 65 66 67 |
# File 'lib/ruby-progressbar/components/bar.rb', line 63 def (length) self.length = length integrated_percentage_complete_string end |
#complete_bar(length) ⇒ Object
41 42 43 44 45 |
# File 'lib/ruby-progressbar/components/bar.rb', line 41 def (length) self.length = length to_s(:format => :standard) end |
#complete_bar_with_percentage(length) ⇒ Object
47 48 49 50 51 |
# File 'lib/ruby-progressbar/components/bar.rb', line 47 def (length) self.length = length to_s(:format => :integrated_percentage) end |
#incomplete_space(length) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/ruby-progressbar/components/bar.rb', line 53 def incomplete_space(length) self.length = length if progress.unknown? unknown_string else incomplete_string end end |
#to_s(options = { :format => :standard }) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby-progressbar/components/bar.rb', line 25 def to_s( = { :format => :standard }) if progress.unknown? unknown_string elsif [:format] == :standard "#{standard_complete_string}#{incomplete_string}" elsif [:format] == :integrated_percentage "#{integrated_percentage_complete_string}#{incomplete_string}" end end |