Class: Kettle::Gha::Pins::CacheProgress
- Inherits:
-
Object
- Object
- Kettle::Gha::Pins::CacheProgress
- Defined in:
- lib/kettle/gha/pins/cache_progress.rb
Constant Summary collapse
- FORMAT =
"%<title>s [:bar] :current/:total"- WIDTH =
30
Instance Attribute Summary collapse
-
#cached_count ⇒ Object
readonly
Returns the value of attribute cached_count.
-
#live_count ⇒ Object
readonly
Returns the value of attribute live_count.
-
#skipped_count ⇒ Object
readonly
Returns the value of attribute skipped_count.
Instance Method Summary collapse
- #cached ⇒ Object
-
#initialize(total:, cached_title:, live_title:, output:, enabled: true, skipped_title: nil) ⇒ CacheProgress
constructor
A new instance of CacheProgress.
- #live ⇒ Object
- #skipped ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(total:, cached_title:, live_title:, output:, enabled: true, skipped_title: nil) ⇒ CacheProgress
Returns a new instance of CacheProgress.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 12 def initialize(total:, cached_title:, live_title:, output:, enabled: true, skipped_title: nil) @total = total.to_i @cached_count = 0 @live_count = 0 @skipped_count = 0 @multibar = progress_enabled?(enabled, output) ? TTY::ProgressBar::Multi.new(output: output, width: WIDTH) : nil @cached_bar = (cached_title) @live_bar = (live_title) @skipped_bar = skipped_title ? (skipped_title) : nil end |
Instance Attribute Details
#cached_count ⇒ Object (readonly)
Returns the value of attribute cached_count.
23 24 25 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 23 def cached_count @cached_count end |
#live_count ⇒ Object (readonly)
Returns the value of attribute live_count.
23 24 25 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 23 def live_count @live_count end |
#skipped_count ⇒ Object (readonly)
Returns the value of attribute skipped_count.
23 24 25 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 23 def skipped_count @skipped_count end |
Instance Method Details
#cached ⇒ Object
25 26 27 28 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 25 def cached @cached_count += 1 @cached_bar&.advance end |
#live ⇒ Object
30 31 32 33 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 30 def live @live_count += 1 @live_bar&.advance end |
#skipped ⇒ Object
35 36 37 38 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 35 def skipped @skipped_count += 1 @skipped_bar&.advance end |
#stop ⇒ Object
40 41 42 |
# File 'lib/kettle/gha/pins/cache_progress.rb', line 40 def stop @multibar&.stop end |