I have this piece of code:
def wait_for_input regex
print "> ".red
someInput = gets
while (regex =~ someInput).is_a? NilClass do
print "\r> ".red
someInput = gets
STDOUT.flush
end
someInput
end
The carriage return is supposed to overwrite the current line in console, but instead doesn't and the ">" goes in new line.
I tried removing the color from the string (library colorize
) and writing $stdout.flush
or STDOUT.flush
following this topic with no luck.
Then I realized that it works if I remove the gets
instruction.
How to overwrite the current line after gets
?