Skip to content

Instantly share code, notes, and snippets.

@srMarquinho
Last active February 21, 2018 10:31
Show Gist options
  • Save srMarquinho/5295a155908b2e12dfd99d2cc77cdbb8 to your computer and use it in GitHub Desktop.
Save srMarquinho/5295a155908b2e12dfd99d2cc77cdbb8 to your computer and use it in GitHub Desktop.
ruby_shell_spinner
# 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