Hello, anyone can help me with the conversion of single quotes in a string to double quotes? Am new to Ruby programming and still learning around on how to use it properly.

I have an example in Delphi, which I want to make compatible with Ruby:

function ReplaceSingleQuote(AText: String): String;
    Result := '';
    if Length(AText) = 0 then
    Result := StringReplace(AText, '''', '''''', [rfReplaceAll]);

Use gsub. First argument is the item you want to change (can be string or regex) the second is what you want to change it to.

s = "this 'string' has embedded single 'quotes'"
s.gsub("'", '"')
# => "this \"string\" has embedded single \"quotes\""