Class: OsCtld::ProgressTracker
- Inherits:
-
Object
- Object
- OsCtld::ProgressTracker
- Defined in:
- lib/osctld/progress_tracker.rb
Instance Method Summary collapse
- #add_total(total) ⇒ Object
-
#initialize(progress: 0, total: 0) ⇒ ProgressTracker
constructor
A new instance of ProgressTracker.
- #progress_line(message, increment_by: 1) ⇒ Object
Constructor Details
#initialize(progress: 0, total: 0) ⇒ ProgressTracker
Returns a new instance of ProgressTracker.
3 4 5 6 7 |
# File 'lib/osctld/progress_tracker.rb', line 3 def initialize(progress: 0, total: 0) @progress = progress @total = total @mutex = Mutex.new end |
Instance Method Details
#add_total(total) ⇒ Object
9 10 11 |
# File 'lib/osctld/progress_tracker.rb', line 9 def add_total(total) @mutex.synchronize { @total += total } end |
#progress_line(message, increment_by: 1) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/osctld/progress_tracker.rb', line 15 def progress_line(, increment_by: 1) @mutex.synchronize do @progress += increment_by if increment_by "[#{@progress}/#{@total}] #{}" end end |