On Fri, Aug 21, 2009 at 3:35 PM, Hunt Jon<jona.hunt777 / gmail.com> wrote:
> I have a ruby script, which takes about 20 seconds to execute.
>
> I want to show a dot (.) sign each second.
>
> I think I need to use "sleep" method and a loop,
> but I don't know how to add the functionality to my script.
>
> Any help would be appreciated.
>
>

If you want to do that I think you would need a thread for that purpose.
Does your script now print nothing for that 20 seconds?

If so, you could print a dot after each step of your program finishes.
Then when you see the last dot, it will be finished, whether it took
19 seconds or 22 seconds, or whatever.
Just a suggestion.

(0..3_000_000).to_a #Fake busy time
print "."
STDOUT.flush

(0..3_000_000).to_a #Next process, etc.
print "."
STDOUT.flush

(0..3_000_000).to_a
print "."
STDOUT.flush

(0..3_000_000).to_a
print "."
STDOUT.flush

puts


Harry

-- 
A Look into Japanese Ruby List in English
http://www.kakueki.com/ruby/list.html