Don't bother using backslashes for paths with Ruby.
Like many other languages, Ruby is aware of the platform and will automagically transform the path slashes to the correct direction for the platform. That means you can ALWAYS use forward slashes in paths, and be done with it:
From the documentation for IO:
Ruby will convert pathnames between different operating system conventions if possible. For instance, on a Windows system the filename “/gumby/ruby/test.rb” will be opened as “\gumby\ruby\test.rb”. When specifying a Windows-style filename in a Ruby string, remember to escape the backslashes:
"c:\\gumby\\ruby\\test.rb"
Our examples here will use the Unix-style forward slashes; File::SEPARATOR can be used to get the platform-specific separator character.
As added information, the problem you're seeing with "path\to\something"
having an escaped \s
and \t
is because the string is in double-quotes. If it was in single-quotes the problem wouldn't occur, because back-slashes lose their magic then. See "Backslashes in Single quoted strings vs. Double quoted strings in Ruby?" for more information.