/gist:a9872c086d963a7665ac Secret
Created
April 3, 2012 20:05
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 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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment