Created
June 22, 2009 14:03
-
-
Save stepahn/133979 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Spinner | |
CHARS = %w{- \\ | / } | |
def initialize | |
@step=-1 | |
end | |
def to_s | |
"\r#{char}" | |
end | |
def method_name | |
end | |
def char | |
CHARS[@step%CHARS.length] | |
end | |
def next | |
@step+= 1 | |
self | |
end | |
end | |
s=Spinner.new | |
10.times do | |
sleep 0.3 | |
print s.next | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment