Skip to content

Instantly share code, notes, and snippets.

@jotto
Created April 28, 2009 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jotto/103398 to your computer and use it in GitHub Desktop.
Save jotto/103398 to your computer and use it in GitHub Desktop.
class Float
def to_percent
(self*100).to_s.gsub(/(.\.)(\d\d).*/,'\1\2')
end
end
$stdout.sync = true
def spinner(i)
return(['\\','|','/','-'][i%4])
end
150.times do |i|
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bWorking: %s %3.2f%s ",spinner(i),((i.to_f/150.0)).to_f.to_percent,"%")
sleep 0.1;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment