IO.try_convert(obj) â io or nil
Class Public methods
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>
Please login to continue.