End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
IO#raw
io.raw(min: nil, time: nil, intr: nil) {|io| }
ext/io/console/console.c
View on GitHub ↗
static VALUE
console_raw(int argc, VALUE *argv, VALUE io)
{
rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
return ttymode(io, rb_yield, io, set_rawmode, optp);
}
Yields self within raw mode, and returns the result of the block.
Example
STDIN.raw(&:gets)
will read and return a line without echo back and line editing.
The parameter min specifies the minimum number of bytes that should be received when a read operation is performed. (default: 1)
The parameter time specifies the timeout in seconds with a precision of 1/10 of a second. (default: 0)
If the parameter intr is true, enables break, interrupt, quit, and suspend special characters.
Refer to the manual page of termios for further details.
You must require ‘io/console’ to use this method.