Created
April 2, 2014 17:45
-
-
Save ritec/9939236 to your computer and use it in GitHub Desktop.
Percentage Tracker in Console Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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