The Shellwords module (part of the standard library) will perform appropriate escaping of shell commands:
require 'shellwords'
command = ['cat', 'filename with spaces', '"quoted_filename"'].shelljoin
puts command
system(command)
shellwords shellescape String.
API. 1.9 Pickaxe , , 1.8.7. ( , /usr/lib/ruby/ 1.8/shelljoin.rb) .