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.



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

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

Instance Method Details

#finishObject



150
151
152
153
154
155
# File 'lib/fontist/utils/downloader.rb', line 150

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



144
145
146
147
148
# File 'lib/fontist/utils/downloader.rb', line 144

def increment(progress)
  @counter = progress

  print_incrementally
end

#total=(total) ⇒ Object



140
141
142
# File 'lib/fontist/utils/downloader.rb', line 140

def total=(total)
  @total = total
end