method
try_convert
v1_9_1_378 -
Show latest stable
- Class:
IO
try_convert(p1)public
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 require 'zlib' f = open("/tmp/zz.gz") # => #<File:/tmp/zz.gz> z = Zlib::GzipReader.open(f) # => #<Zlib::GzipReader:0x81d8744> IO.try_convert(z) # => #<File:/tmp/zz.gz>