Skip to content

Instantly share code, notes, and snippets.

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