Created
April 21, 2012 22:24
-
-
Save jordelver/2439978 to your computer and use it in GitHub Desktop.
Command line progress spinner
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
# Command line progress spinner | |
# As seen here: http://www.youtube.com/watch?v=W-4vEZp67b0 | |
require 'thread' | |
require 'open-uri' | |
Thread.abort_on_exception = true | |
class Spinner | |
GLYPHS = ['|', '/', '-', '\\', '|', '/', '-', '\\'] | |
def render | |
Thread.new do | |
while true | |
GLYPHS.each do |glyph| | |
print "\r#{glyph}" | |
sleep 0.15 | |
end | |
end | |
print "\r" | |
end | |
end | |
end | |
spinner = Spinner.new | |
spinner.render | |
response = open('http://wikipedia.org').read | |
puts response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment