Created
November 1, 2010 07:58
-
-
Save lexer/657798 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
STDOUT.sync = true | |
def loadify(message = "", &block) | |
characters = %w[| / - \\ | / - \\] | |
thread = Thread.new do | |
block.call | |
end | |
while thread.alive? | |
next_character = characters.shift | |
output = "#{next_character} #{message}" | |
print output | |
characters << next_character | |
sleep 0.1 | |
print "\b" * (output.length) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment