Last active
February 21, 2018 10:31
-
-
Save srMarquinho/5295a155908b2e12dfd99d2cc77cdbb8 to your computer and use it in GitHub Desktop.
ruby_shell_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
# tested ruby 1.8 | |
class Spinner | |
include Enumerable | |
def each | |
loop do | |
yield '|' | |
yield '/' | |
yield '-' | |
yield '\\' | |
end | |
end | |
end | |
spinner = Spinner.new.enum_for(:each) | |
# print this inside the loop | |
print spinner.next | |
print "\r" | |
$stdout.flush |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment