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



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

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

Instance Method Details

#finishObject



137
138
139
140
141
# File 'lib/fontist/utils/downloader.rb', line 137

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



131
132
133
134
135
# File 'lib/fontist/utils/downloader.rb', line 131

def increment(progress)
  @counter = progress

  print_incrementally
end

#total=(total) ⇒ Object



127
128
129
# File 'lib/fontist/utils/downloader.rb', line 127

def total=(total)
  @total = total
end