Skip to content

Instantly share code, notes, and snippets.

@rhzs
Created August 8, 2015 18:20
Show Gist options
  • Save rhzs/b354593d2a36ef616f64 to your computer and use it in GitHub Desktop.
Save rhzs/b354593d2a36ef616f64 to your computer and use it in GitHub Desktop.
Ruby Terminal Progress Bar Example
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