Module: Bonito::ProgressCounter
- Included in:
- ProgressBar, ProgressLogger
- Defined in:
- lib/bonito/progress.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods Classes: Unknown
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
- #increment(change) ⇒ Object
- #setup(total: ProgressCounter::Unknown.instance, prefix: nil) ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
9 10 11 |
# File 'lib/bonito/progress.rb', line 9 def current @current end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
8 9 10 |
# File 'lib/bonito/progress.rb', line 8 def total @total end |
Class Method Details
.included(base) ⇒ Object
24 25 26 |
# File 'lib/bonito/progress.rb', line 24 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#increment(change) ⇒ Object
34 35 36 37 38 |
# File 'lib/bonito/progress.rb', line 34 def increment(change) @current += change on_increment change self end |
#setup(total: ProgressCounter::Unknown.instance, prefix: nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/bonito/progress.rb', line 28 def setup(total: ProgressCounter::Unknown.instance, prefix: nil) @total = total @prefix = prefix @current = 0 end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/bonito/progress.rb', line 40 def to_s "#{prefix} #{current} / #{total}" end |