Reputation: 483
I am iterating over a config.yml from from which parsing the values in a string form as follows:
machines:
A:
ip: 10.11.12
pass: vass
B:
ip: 10.11.13
pass: grass
The above config.yml is parsed as follows:
machines = YAML.load_file('machine.yml')
var=''
machines[A].each do |letters,hash|
var += "[" + hash['ip'] + "]\n" + hash['pass'] + "\n"
end
The "var" value i am getting as :
"[10.11.12]\nvass\n[10.11.13]\ngrass\n"
but instead like above i dont want double quotes rather single quotes across complete atring as follows:
'[10.11.12]\nvass\n[10.11.13]\ngrass\n'
So, please suggest how can have single quotes across the string.
Upvotes: 0
Views: 3101
Reputation: 11544
Generally the puts
will print the value of the string without double quotes in the console.
So may be you can use puts var
so that double quotes are not getting printed. And now you can wrap your content with single quote using string interpolation.
var += "'#{actual_value}'"
Upvotes: 1