Skip to content

Instantly share code, notes, and snippets.

@noeticpenguin
Created April 3, 2012 20:05
Show Gist options
  • Save noeticpenguin/a9872c086d963a7665ac to your computer and use it in GitHub Desktop.
Save noeticpenguin/a9872c086d963a7665ac to your computer and use it in GitHub Desktop.
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