Created
June 15, 2013 23:16
-
-
Save nviennot/5789975 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
def to_human(t) | |
ms = ((t-t.floor)*10).floor | |
sec = t.floor | |
hour = (sec/3600).floor | |
sec -= hour * 3600 | |
min = (sec/60).floor | |
sec -= min * 60 | |
sprintf "%02d:%02d:%02d.%01d", hour, min, sec, ms | |
end | |
Kernel.trap('INT') { Kernel.exit } | |
start = Time.now | |
loop do | |
elapsed = Time.now - start | |
sleep 0.1 | |
print "\b"*30 | |
print to_human(elapsed) | |
print " "*5 | |
STDOUT.flush | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment