Skip to content

End of Life Ruby 3.2 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| }

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.

See also #raw! #pwrite #puts #read also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0