Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@coop
Created July 7, 2010 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coop/466315 to your computer and use it in GitHub Desktop.
Save coop/466315 to your computer and use it in GitHub Desktop.
Given this result set (this cannot be modified) that looks like:
[{"client name"=>"Adenbrook (Avalon Franchising Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"TCo", "job name"=>"INTR - 1300 Phone Charges 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ADN2611"}, {"client name"=>"Adenbrook Homes (Morris Family Building Trust)", "job status wip c"=>"WIP", "job owner"=>"NSe", "job name"=>"PREL: Fixed Display Centre: Port Macquarie", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MBT2763"}, {"client name"=>"Media Shop", "job status wip c"=>"WIP", "job owner"=>"TCo", "job name"=>"Media Shop: Polypropylene folder - Contract & Documents", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MED2801"}, {"client name"=>"Adenbrook Homes (Toolona NSW Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"Media Shop: Tweed Richmond June 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ATR2817"}, {"client name"=>"Adenbrook (Avalon Franchising Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"PREL: Adenbrook Customer Service Survey: Online Implementation", "job billable"=>nil, "__uid"=>#, "invoice lock"=>nil, "job no"=>"ADN986"}, {"client name"=>"Home Expert Centre", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"PRNT: Home Expert Magazine: Small Format: Issue 3", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MES2482"}, {"client name"=>"Adenbrook (Avalon Franchising Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"DSGN: Adenbrook Homes: Guidelines Vehicle Brand: 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ADN2717"}]
I would like to create a hash that looks like (grouped by the job owner):
{ "TCo" => [
{"client name"=>"Adenbrook (Avalon Franchising Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"TCo", "job name"=>"INTR - 1300 Phone Charges 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ADN2611"},
{"client name"=>"Media Shop", "job status wip c"=>"WIP", "job owner"=>"TCo", "job name"=>"Media Shop: Polypropylene folder - Contract & Documents", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MED2801"},
],
"NSe" => [
{"client name"=>"Adenbrook Homes (Morris Family Building Trust)", "job status wip c"=>"WIP", "job owner"=>"NSe", "job name"=>"PREL: Fixed Display Centre: Port Macquarie", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MBT2763"}
]
"CCo" => [
{"client name"=>"Home Expert Centre", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"PRNT: Home Expert Magazine: Small Format: Issue 3", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MES2482"},
{"client name"=>"Adenbrook (Avalon Franchising Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"DSGN: Adenbrook Homes: Guidelines Vehicle Brand: 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ADN2717"},
{"client name"=>"Adenbrook Homes (Toolona NSW Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"Media Shop: Tweed Richmond June 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ATR2817"},
{"client name"=>"Adenbrook (Avalon Franchising Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"PREL: Adenbrook Customer Service Survey: Online Implementation", "job billable"=>nil, "__uid"=>#, "invoice lock"=>nil, "job no"=>"ADN986"}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment