Class: Kettle::Dev::CacheProgress

Inherits:
Object
  • Object
show all
Defined in:
lib/kettle/dev/cache_progress.rb

Constant Summary collapse

FORMAT =
"%<title>s [:bar] :current/:total"
WIDTH =
30

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total:, cached_title:, live_title:, output:, enabled: true, skipped_title: nil) ⇒ CacheProgress

Returns a new instance of CacheProgress.



11
12
13
14
15
16
17
18
19
20
# File 'lib/kettle/dev/cache_progress.rb', line 11

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 = progress_bar(cached_title)
  @live_bar = progress_bar(live_title)
  @skipped_bar = skipped_title ? progress_bar(skipped_title) : nil
end

Instance Attribute Details

#cached_countObject (readonly)

Returns the value of attribute cached_count.



22
23
24
# File 'lib/kettle/dev/cache_progress.rb', line 22

def cached_count
  @cached_count
end

#live_countObject (readonly)

Returns the value of attribute live_count.



22
23
24
# File 'lib/kettle/dev/cache_progress.rb', line 22

def live_count
  @live_count
end

#skipped_countObject (readonly)

Returns the value of attribute skipped_count.



22
23
24
# File 'lib/kettle/dev/cache_progress.rb', line 22

def skipped_count
  @skipped_count
end

Instance Method Details

#cachedObject



24
25
26
27
# File 'lib/kettle/dev/cache_progress.rb', line 24

def cached
  @cached_count += 1
  @cached_bar&.advance
end

#liveObject



29
30
31
32
# File 'lib/kettle/dev/cache_progress.rb', line 29

def live
  @live_count += 1
  @live_bar&.advance
end

#skippedObject



34
35
36
37
# File 'lib/kettle/dev/cache_progress.rb', line 34

def skipped
  @skipped_count += 1
  @skipped_bar&.advance
end

#stopObject



39
40
41
# File 'lib/kettle/dev/cache_progress.rb', line 39

def stop
  @multibar&.stop
end