I want to build the following YAML formatting from an array / hash:
Name: gender: - female nationality: - german - danish
Now I have such an array:
names = ["Abbie", "Abeline", "Abelone"]
What would be the easiest way to get from this array to YAML?
I tried converting it to a hash by adding values ββfor gender and nationality:
names.each do |name| (META_HASH ||= Hash.new) = name => { gender: 'female', nationality: ['german', 'danish'] } end
This, however, just gives me a syntax error. Any help in converting this would be much appreciated!
arrays ruby ruby-on-rails yaml hash
Severin
source share