select(reads, writes = [], excepts = [], timeout = nil) -> [[IO]] | nil[permalink][rdoc]select(2) を実行します。
与えられた入力/出力/例外待ちの IO オブジェクトの中から準備ができたものをそれぞれ配列にして、配列の配列として返します。タイムアウトした時には nil を返します。
rp, wp = IO.pipe
mesg = "ping "
100.times{
  rs, ws, = IO.select([rp], [wp])
  if r = rs[0]
    ret = r.read(5)
    print ret
    case ret
    when /ping/
      mesg = "pong\n"
    when /pong/
      mesg = "ping "
    end
  end
  if w = ws[0]
    w.write(mesg)
  end
}
[SEE_ALSO] Kernel.#select