Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > IOクラス > try_convert

singleton method IO.try_convert

try_convert(obj) -> IO | nil

Try to convert obj into an IO, using to_io method. Returns converted IO or nil if obj cannot be converted for any reason.

IO.try_convert(STDOUT)     # => STDOUT
IO.try_convert("STDOUT")   # => nil