Skip to content

Instantly share code, notes, and snippets.

@tithonium
Last active May 13, 2022 17:11
Show Gist options
  • Save tithonium/403dcb7fa7cb0d046cc56c5d0c480450 to your computer and use it in GitHub Desktop.
Save tithonium/403dcb7fa7cb0d046cc56c5d0c480450 to your computer and use it in GitHub Desktop.
Spinner - I had a long-running process that I didn't want to make spammy, but wanted to know it was /going/. So...
SPINNER = ("\u2800".."\u28ff").to_a.shuffle
def spinner
if @spinstep.nil?
@spinstep = 0
else
return if (Time.now - @spintime) < 0.1
STDOUT.print "\b \b"
end
@spintime = Time.now
STDOUT.print SPINNER[(@spinstep += 1) % SPINNER.length]
end
def unspinner
if @spinstep
STDOUT.puts "\b \b"
@spinstep = nil
@spintime = nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment