Class: Bcome::ProgressBar
- Inherits:
-
Object
- Object
- Bcome::ProgressBar
- Includes:
- Singleton
- Defined in:
- lib/objects/progress_bar.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #increment! ⇒ Object
- #indicate(config, in_progress) ⇒ Object
- #indicate_and_increment!(config, in_progress) ⇒ Object
-
#initialize ⇒ ProgressBar
constructor
A new instance of ProgressBar.
- #reset! ⇒ Object
Constructor Details
#initialize ⇒ ProgressBar
Returns a new instance of ProgressBar.
7 8 9 |
# File 'lib/objects/progress_bar.rb', line 7 def initialize @count = 0 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
5 6 7 |
# File 'lib/objects/progress_bar.rb', line 5 def count @count end |
Instance Method Details
#increment! ⇒ Object
11 12 13 |
# File 'lib/objects/progress_bar.rb', line 11 def increment! @count += 1 end |
#indicate(config, in_progress) ⇒ Object
19 20 21 22 23 |
# File 'lib/objects/progress_bar.rb', line 19 def indicate(config, in_progress) prefix = in_progress ? config[:prefix].progress : config[:prefix].progress = prefix + "#{config[:indice] * @count}>" + " (#{@count} #{config[:indice_descriptor]})".progress + "\r" print end |
#indicate_and_increment!(config, in_progress) ⇒ Object
25 26 27 28 |
# File 'lib/objects/progress_bar.rb', line 25 def indicate_and_increment!(config, in_progress) increment! indicate(config, in_progress) end |
#reset! ⇒ Object
15 16 17 |
# File 'lib/objects/progress_bar.rb', line 15 def reset! @count = 0 end |