Created
August 8, 2015 18:20
-
-
Save rhzs/b354593d2a36ef616f64 to your computer and use it in GitHub Desktop.
Ruby Terminal Progress Bar Example
This file contains 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
progress = 'Progress... [' | |
1000.times do |i| | |
j = i + 1 | |
# add 1 percent every 10 times | |
if j % 10 == 0 | |
progress << "=" | |
print "\r" | |
print progress + " #{j / 10} %]" | |
# Force to flush the buffer so that the output appears immediately.. | |
$stdout.flush | |
sleep 0.1 | |
end | |
end | |
puts "\nFinish!!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment