Method: U3d::Utils.print_progress
- Defined in:
- lib/u3d/utils.rb
.print_progress(current, total, started_at) ⇒ Object
if total is nil (unknown, falls back to print_progress_nosize)
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/u3d/utils.rb', line 185 def print_progress(current, total, started_at) if total.nil? print_progress_nosize(current, started_at) return end ratio = [current.to_f / total, 1.0].min percent = (ratio * 100.0).round(1) arrow = (ratio * 20.0).floor time_spent = Time.now.to_i - started_at print("\r[") print('=' * [arrow - 1, 0].max) print('>') print('.' * (20 - arrow)) print("] #{pretty_filesize(current)}/#{pretty_filesize(total)} (#{percent}% at #{pretty_filesize(current.to_f / time_spent)}/s) ") end |