title: Smart conversion of single to double quotes in Ruby
body: <h1>Problem</h1>
  
  <p>In a source file, I have a large number of strings.ome with interpolation, some with special symbols and some with neither.</p>
  
  <p>I am trying to work out if I can replace the single quotes with double quotes whilst converting escaped single quote characters. I would then run this conversion on one or more source code files.</p>
  
  <h1>Example - Code</h1>
  
  <p>Imagine the following code:</p>
  
  <pre><code>def myfunc(var, var2 = 'abc')
    s = 'something'
    puts 'a simple string'
    puts 'string with an escaped quote \' in it'
    x = "nasty #{interpolated}" + s + ' and single quote combo'
    puts "my #{var}"
  end
  </code></pre>
  
  <h1>Example - Result</h1>
  
  <p>I would like to turn it into this:</p>
  
  <pre><code>def myfunc(var, var2 = "abc")
    s = "something"
    puts "a simple string"
    puts "string with an escaped quote ' in it"
    x = "nasty #{interpolated}" + s + " and single quote combo"
    puts "my #{var}"
  end
  </code></pre>
  
  <p>If anyone has any ideas I'd be very grateful!</p>