Class: Fontist::Utils::ProgressBar

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/utils/downloader.rb

Direct Known Subclasses

NullProgressBar

Instance Method Summary collapse

Constructor Details

#initialize(total) ⇒ ProgressBar

Returns a new instance of ProgressBar.



110
111
112
113
114
115
116
# File 'lib/fontist/utils/downloader.rb', line 110

def initialize(total)
  @counter = 0
  @total  = total
  @printed_percent = -1
  @printed_size = -1
  @start = Time.now
end

Instance Method Details

#finishObject



128
129
130
131
132
# File 'lib/fontist/utils/downloader.rb', line 128

def finish
  print

  Fontist.ui.print(format(", %<mb_per_second>.2f MiB/s, done.\n", mb_per_second: mb_per_second))
end

#increment(progress) ⇒ Object



122
123
124
125
126
# File 'lib/fontist/utils/downloader.rb', line 122

def increment(progress)
  @counter = progress

  print_incrementally
end

#total=(total) ⇒ Object



118
119
120
# File 'lib/fontist/utils/downloader.rb', line 118

def total=(total)
  @total = total
end