def convert_data_to_io_obj options, &block
data = options.delete(:data)
if block_given?
options[:data] = IOProxy.new(block)
elsif data.is_a?(String)
data.force_encoding("BINARY") if data.respond_to?(:force_encoding)
options[:data] = StringIO.new(data)
elsif data.is_a?(Pathname)
options[:data] = open_file(data.to_s)
elsif io_like?(data)
options[:data] = data
else
msg = "invalid :data option, expected a String, Pathname or "
msg << "an object that responds to #read and #eof?"
raise ArgumentError, msg
end
end