From: Thomas Haggett Date: 2009-10-01T08:15:15+09:00 Subject: Re: Can you make a clock? Hi. Am I missing something or do you just need: Time.now.strftime("%h %d %H:%M:%S") To write to a terminal by replacing existing lines you need to send a carriage-return without a line-feed (i.e. \r rather than \n on the end of lines). If I'm being hacky, I generally just write them directly: $stderr.write "\rstuff here" Just be aware that anything longer than the new line will still be visible (i.e. $stderr.write "\rlong string" $stderr.write "\rshort" will result in "shortstring" being visible. If you want to do this properly, you should probably look at the ncurses library (http://ncurses-ruby.berlios.de/). Thomas On 30 Sep 2009, at 23:54, Scott Andrechek wrote: > 'Ello. I was just wandering how you update the time in a ruby program > (like a clock). For instance: > COMP:WED Sep 30 18:51:30 > COMP:WED Sep 30 18:51:31 #Replacing the above line > > I don't need the entire code for a clock (unless you happen to have > it) > I just need to know the idea of how to make it. Thanks. > > -Scott > -- > Posted via http://www.ruby-forum.com/. >