I am trying to implement a simple "Press any key to continue". I print this message to the console, and I want to erase it after a key is pressed.
Following "Writing over previously output lines in the command prompt with ruby", I tried this piece of code:
def continue
print "Press any key to continue\r"
gets
end
puts "An awesome story begins..."
continue
puts "And ends after 2 lines"
However, the \r
trick doesn't work and the next puts
won't erase the sentence. Is it because of a different function context? The gets
spawns a newline? Or because I'm on Windows OS?