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.



165
166
167
168
169
170
171
# File 'lib/fontist/utils/downloader.rb', line 165

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

Instance Method Details

#finishObject



183
184
185
186
187
188
# File 'lib/fontist/utils/downloader.rb', line 183

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



177
178
179
180
181
# File 'lib/fontist/utils/downloader.rb', line 177

def increment(progress)
  @counter = progress

  print_incrementally
end

#total=(total) ⇒ Object



173
174
175
# File 'lib/fontist/utils/downloader.rb', line 173

def total=(total)
  @total = total
end