Created
September 28, 2011 01:01
-
-
Save mrcsparker/1246729 to your computer and use it in GitHub Desktop.
Sample hacky Ruby progress bar
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
def progress(percent) | |
left = 100 - percent | |
STDOUT.write "\r\e[0K" # clear cursor to the end of line | |
STDOUT.write "[#{'#' * percent}#{'.' * left}]\t[ #{percent}/100 ]" | |
STDOUT.flush | |
end | |
1.upto(100) do |i| | |
progress(i) | |
sleep(1) | |
end |
Author
mrcsparker
commented
Sep 28, 2011
via email
haha.
"\r\e[0K" is so awful.
…On Tue, Sep 27, 2011 at 9:02 PM, David B ***@***.*** wrote:
Awesome! That's what I'm talking about.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1246729
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment