I'm looking for a method in Ruby which is basically this:
io.ready_for_read?
I just want to check whether a given IO
object (in my case, the result of a popen
call) has output available, i.e. a follow up call io.read(1)
will not block.
These are the two options I see, neither of which I like:
io.read_nonblock
- too thin an abstraction of Unixread()
-- I don't want to deal witherrno
error handling.io.select
with timeout 0 -- obfuscates the purpose of this simple operation.
Is there a better alternative that I have overlooked?