Skip to content

Instantly share code, notes, and snippets.

@ritec
Created April 2, 2014 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritec/9939236 to your computer and use it in GitHub Desktop.
Save ritec/9939236 to your computer and use it in GitHub Desktop.
Percentage Tracker in Console Example
#from http://brettu.com/category/rails/page/2/
@photos = Photo.all
count = @photos.count
@photos.each_with_index do |photo, idx|
# ... do a bunch of processing
puts "#{(100.0 * idx / count).round(2)}%"
end
# When the script is run we will get a percentage complete counter like:
#=> 0.1%
#=> 0.2%
#=> 0.3%
#=> 0.4%
#=> ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment