/gist:9cdb31c3e206838cf592 Secret
Created
April 3, 2012 20:15
-
-
Save babney/9cdb31c3e206838cf592 to your computer and use it in GitHub Desktop.
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
module Spinner | |
def spinner(&block) | |
return unless block_given? | |
chars = %w{ | / - \\ } | |
t = Thread.new { yield if block_given? } | |
while t.alive? | |
print chars[0] | |
sleep 0.1 | |
print "\b" | |
chars.push chars.shift | |
end | |
#t.join | |
return t.value | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment