On 11/7/06, darenbell / gmail.com <darenbell / gmail.com> wrote:
> Hi, I'm looking for a way to implement this idea:
>
>
> -------------------------------------
> count=1
> total=15
>
> until count>total
>   print "Record #{count} of #{total} processed."
>   count+=1
> end
> -------------------------------------
>
>

$ cat tmp.rb

STDOUT.sync = true

total = ARGV[0] || 15
count = 1

until count>total
  print "\rRecord #{count} of #{total} processed"
  count += 1
  sleep 0.25
end

print "\n"


That should do you what you want.  The secret is the carriage return
"\r" at the beginning of the print string. That will bring the cursor
back to the beginning of the line and then overwrite anything
currently on that line.

Blessings,
TwP