What is the best way when collecting data to create a has of hashes?
So say this was my expected result.
{ Id:123 { id:1, name:John},{id:2, name: Sarah}}
{"Id:123"=>[{:id=>1, :name=>"John"}, {:id=>2, :name=>"Sarah"}]}
{:Id=>123, :members=>[{:id=>1, :name=>"John"}, {:id=>2, :name=>"Sarah"}]}
So that I am saying Sarah and John are members of group id: 123.
This is not a valid representation of a Hash. Which of these do you want?
irb(main):001:0> { 'Id:123' => [{id:1, name:'John'}, {id:2, name:'Sarah'}]}
{"Id:123"=>[{:id=>1, :name=>"John"}, {:id=>2, :name=>"Sarah"}]}
irb(main):002:0> { Id:123, members: [{id:1, name:'John'}, {id:2, name:'Sarah'}]}
{:Id=>123, :members=>[{:id=>1, :name=>"John"}, {:id=>2, :name=>"Sarah"}]}
...
So that I am saying Sarah and John are members of group id: 123.
That depends on your input and how you access it.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
Is there a particular benefit of one over the other? I want to be
able to keep the relation between ids and descendant nodes and then put this into a database, is one more suitable than the other?
The data I will be collecting from XML has a snowflake schema based
around, though there are changes I want to make from first version.
At this stage i just want to ensure I maintain the relationship of
each person and id to the event id and will create some json files to
play with charts and display before I parse all files and push to
database.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 58:51:29 |
Calls: | 6,653 |
Calls today: | 5 |
Files: | 12,200 |
Messages: | 5,331,149 |