D
dara
I have been trying to include variable references in a yaml file. I
have a feeling it's not possible to do this, but I thought I'd ask
here before giving up.
Here is my ruby script:
require 'yaml'
hash = YAML.load_file('sampl.yml')
fourth_member = 'Joan'
hash.each_pair do |key, value|
puts "Value for key \"#{key}\" is: \"#{value}\""
end
puts "\nFrom within script, \"fourth\" is: #{fourth_member}"
The contents of sampl.yml are:
:first: 'John'
:second: 'Jane'
:third: 'Jack'
:fourth: "#{fourth_member}"
The output of the script is:
Value for key "first" is: "John"
Value for key "second" is: "Jane"
Value for key "third" is: "Jack"
Value for key "fourth" is: "#{fourth_member}"
From within script, "fourth" is: Joan
I want the fourth line of the output to read:
"Value for key "fourth" is: "Joan""
I have done much googling and tried every possible permutation of
escape characters I could think of, with no success. Can anyone
either:
1) Show me a way to do this (much preferred ).
2) Confirm this can't be done (would at least save me wasting further
time on it).
Thanks,
-Dara
have a feeling it's not possible to do this, but I thought I'd ask
here before giving up.
Here is my ruby script:
require 'yaml'
hash = YAML.load_file('sampl.yml')
fourth_member = 'Joan'
hash.each_pair do |key, value|
puts "Value for key \"#{key}\" is: \"#{value}\""
end
puts "\nFrom within script, \"fourth\" is: #{fourth_member}"
The contents of sampl.yml are:
:first: 'John'
:second: 'Jane'
:third: 'Jack'
:fourth: "#{fourth_member}"
The output of the script is:
Value for key "first" is: "John"
Value for key "second" is: "Jane"
Value for key "third" is: "Jack"
Value for key "fourth" is: "#{fourth_member}"
From within script, "fourth" is: Joan
I want the fourth line of the output to read:
"Value for key "fourth" is: "Joan""
I have done much googling and tried every possible permutation of
escape characters I could think of, with no success. Can anyone
either:
1) Show me a way to do this (much preferred ).
2) Confirm this can't be done (would at least save me wasting further
time on it).
Thanks,
-Dara