I'm new to Ruby and still learning about hashes. I've tried looking here for other similar answers but wasn't able to find anything that completely answered my question.
I have some data stored in a hash structure that I'm feeding into a script that updates a Neo4j database ( so this data structure is important ):
data = {
a: [
{
label: 'Person',
title: 'Manager',
name: 'Mike Waldo'
},
{
label: 'Person',
title: 'Developer',
name: 'Jeff Smith',
},
],
b: [
{
type: 'ABC',
source: 'abcde',
destination: ['Jeff Dudley', 'Mike Wells', 'Vanessa Jones']
}
]
}
I've figured out how to return individual values:
data.each{|x, y| puts y[0][:name]}
Returns: Mike Waldo
Two questions:
1) How do I return the 'labels', 'titles', and 'names' from array 'a: [ ]' only?
2) How do I add and save a new hash under array 'a: [ ]' but not ':b [ ]'?
Thanks in advance for the help!