Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

IO#wait

io.wait(events, timeout) → event mask, false or nil
io.wait(timeout = nil, mode = :read) → self, true, or false

Waits until the IO becomes ready for the specified events and returns the subset of events that become ready, or a falsy value when times out.

The events can be a bit mask of IO::READABLE, IO::WRITABLE or IO::PRIORITY.

Returns a truthy value immediately when buffered data is available.

Optional parameter mode is one of :read, :write, or :read_write.

You must require ‘io/wait’ to use this method.

See also #ungetc #wait_priority #ungetbyte #wait_readable also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0