The standard Ruby library "io/wait" provides a method on IO objects ready?
that returns non-nil if there is input available, nil or false otherwise. I know some methods like sysread
and syswrite
are not safe to use with higher level methods such as gets
and read
, and wanted to know if ready?
was safe to mix with the higher level methods. The ready method seems rather useful and perhaps more elegant than relying on IO.select
, but, surprisingly enough, I haven't seen it used much. There is nothing in the documentation to indicate it would be unsafe to use with read
or gets
, I just want to be sure I'm not mixing incompatible methods that could ultimately result in unexpected behavior when reading/writing sockets.
Edit: I suppose I should mention I am using Ruby 1.8.7.