Skip to content

Instantly share code, notes, and snippets.

@jordelver
Created April 21, 2012 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordelver/2439978 to your computer and use it in GitHub Desktop.
Save jordelver/2439978 to your computer and use it in GitHub Desktop.
Command line progress spinner
# 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