Class: Theme::UI::SyncProgressBar

Inherits:
Object
  • Object
show all
Defined in:
lib/project_types/theme/ui/sync_progress_bar.rb

Instance Method Summary collapse

Constructor Details

#initialize(syncer) ⇒ SyncProgressBar

Returns a new instance of SyncProgressBar.



4
5
6
# File 'lib/project_types/theme/ui/sync_progress_bar.rb', line 4

def initialize(syncer)
  @syncer = syncer
end

Instance Method Details

#progress(method, **args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/project_types/theme/ui/sync_progress_bar.rb', line 8

def progress(method, **args)
  @syncer.lock_io!
  CLI::UI::Progress.progress do |bar|
    @syncer.public_send(method, **args) do |left, total|
      bar.tick(set_percent: 1 - left.to_f / total)
    end
    bar.tick(set_percent: 1)
  end
  @syncer.unlock_io!
end