From: Yaser Sulaiman Date: 2008-11-08T06:20:32+09:00 Subject: Re: Showing a spinner ? ------=_Part_48120_28940194.1226092953627 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline That library looks interesting. Thanks for sharing, Michael! Just want to mention that I tried the same code (posted by Rodrigo) under Windows Vista, and it worked fine without using STDOUT.flush. Regards, Yaser On Fri, Nov 7, 2008 at 3:06 AM, Michael Fellinger wrote: > On Wed, Nov 5, 2008 at 1:22 AM, Rodrigo Bermejo > wrote: > > Aldric Giacomoni wrote: > >> How do I show a spinner on the command line interface when a ruby script > >> is working? I sometimes write things that take a while, and I know I get > >> impatient when all I see a blinking cursor :) > >> A spinner has \ | / - all in one spot so it looks like a spinning wheel. > >> > >> Thanks! > >> > >> --Aldric > > > > Here is the idea ..you can make it better.. > > > > a=["-","\\","|","/"] > > n=0 > > while 1 do > > print a[n % 4] > > print "\b" > > n+=1 > > sleep 0.1 > > puts "..#{n}." if (n % 50==0) > > end > > Just had the same thing lying around to keep ssh alive, not much in > terms of progress though > See http://0xcc.net/ruby-progressbar/index.html.en for a full lib that > handles this problem > > sigma ~prog/ruby % cat spinner.rb > a = %w[ | / - \\ ] > > $stdout.sync = true > > loop do > print a.unshift(a.pop).last > sleep 0.1 > print "\b" > end > > ------=_Part_48120_28940194.1226092953627--