Ok So I am using the calorieking api and it crack as my xml parser (it
comes with httparty which is my consumer gem). Now I need to be able to
list the food names. How can i get data from a hash that contains
arrays? Here is what the hash looks like when pp’ed.
#<HTTParty::Response:0x10368f160
@parsed_response={“searchresults”=>{“category”=>[{“name”=>“Average All
Brands”,
“foods”=>{“food”=>[{“id”=>“f985dcc7-ac8f-4ad5-bbe1-85e71469e023”,
“display”=>“Breast, meat only, roasted”},
{“id”=>“584917be-3ff3-4165-81c3-46ddb69ac35c”, “display”=>“Chicken Egg,
whole, hard-boiled”}, {“id”=>“0a067a58-8c3b-4a15-95d0-8cd54fa69401”,
“display”=>“Chicken Egg, egg white, cooked, no added fat”},
{“id”=>“7b8a89bb-9f43-481a-9e59-750de9c4b98b”, “display”=>“Breast, meat
only, raw”}, {“id”=>“76de8abd-cd6e-40ab-ae44-2824c9a4576a”,
“display”=>“Chicken Egg, whole, raw, fresh”},
{“id”=>“dfaf0fe2-0faa-42ae-82a4-b67ab1d3cbf4”, “display”=>“Chicken Egg,
egg white, hard-boiled”}, {“id”=>“b9d2a52d-e554-4641-b554-d11c3e4442e4”,
“display”=>“Chicken Egg, egg white, raw, fresh”},
{“id”=>“3f57dc04-2d73-4cb0-b7b8-73352e7299c7”, “display”=>“Wing, meat
only, fried, edible portion”},
{“id”=>“d981c191-2e80-4991-af90-b674f18daf35”, “display”=>“Thigh, meat
only, roasted”}, {“id”=>“42e5699f-79cd-436c-965b-90850b26a278”,
“display”=>“Breast Quarters, rotisserie, no skin or wing (Boston
Market)”}, {“id”=>“e04eeaad-801d-454d-b693-6ab306089e50”,
“display”=>“Breast, meat and skin, roasted”},
{“id”=>“06d4735c-5075-4d8a-bdd9-689471c9bbe6”, “display”=>“Leg, meat
only, roasted”}, {“id”=>“0915d043-9c44-470d-b1c1-9e9ac934628a”,
“display”=>“Chicken Egg, egg yolk, raw, fresh”},
{“id”=>“68556c9e-462a-4af1-89cf-04b79a04bdf1”, “display”=>“Wing w. meat
and skin, roasted”}, {“id”=>“64b4fc73-ec8e-411d-8659-0a990d80a04f”,
“display”=>“Breast, meat only, stewed”},
{“id”=>“b35f0582-d1e9-4dff-bf64-1495a1f92f51”, “display”=>“Breast, meat
& skin, fried, batter”}]}}, {“name”=>“McDonald’s”,
“foods”=>{“food”=>[{“id”=>“27dce0ec-8af9-46b0-ad40-ec59a501cdd1”,
“display”=>“Chicken McNuggets”},
{“id”=>“f1045302-9bb0-4018-9c1c-08f4a292c913”, “display”=>“Caesar w.
Grilled Chicken, no dressing”},
{“id”=>“4f6a1e64-3dcc-46b9-b981-933d56255fdd”, “display”=>“Snack Wraps,
Ranch w. Crispy Chicken”},
{“id”=>“67048351-9958-4f4c-b8e7-fb2663549a99”, “display”=>“Asian w.
Grilled Chicken, no dressing”},
{“id”=>“9a5f059e-6608-42c6-b809-02fb35c8949a”, “display”=>“Sandwiches,
Premium Grilled, Chicken Classic”},
{“id”=>“3c020ca7-dd6a-438d-be02-c4c4c78b07f6”, “display”=>“Snack Wraps,
Honey Mustard w.Grilled Chicken”},
{“id”=>“7d59f606-8f68-4ff6-855a-076c32d4d7ec”, “display”=>“Bacon Ranch
w. Grilled Chicken, no dressing”},
{“id”=>“6167852c-5cff-4342-8df9-696909773b6c”, “display”=>“Premium
Chicken Breast Filet, Grilled”},
{“id”=>“e8e84c38-1e97-4d45-be1f-ad4d600b8734”, “display”=>“Southwest w.
Grilled Chicken, no dressing”},
{“id”=>“02ed0335-2aa7-4e38-b489-44eb3cff08af”, “display”=>“Snack Wraps,
Ranch w. Grilled Chicken”},
{“id”=>“10eaa1d4-2ab3-49d2-97d1-a2c772424690”, “display”=>“Chicken
Selects, Premium Breast Strips”}]}}, {“name”=>“Burger King”,
“foods”=>{“food”=>[{“id”=>“de413f0f-dd04-4825-b92d-465439c6cbcc”,
“display”=>“Garden w. TenderGrill Chicken, no dressing or croutons”},
{“id”=>“5bd48435-bceb-473c-a97d-aea374774db4”, “display”=>“Sandwiches,
TenderGrill Chicken w. Honey Mustard Sauce”},
{“id”=>“24432f66-bd83-41f6-bb3c-59cd0076c747”, “display”=>“Sandwiches,
Original Chicken”}]}}]}}, @response=#<Net::HTTPOK 200 OK readbody=true>,
@headers={“expires”=>[“0”], “last-modified”=>[“Thu, 26 Aug 2010 11:58:33
GMT”], “connection”=>[“close”], “content-type”=>[“application/xml”],
“date”=>[“Thu, 26 Aug 2010 11:58:33 GMT”], “server”=>[“Apache”],
“cache-control”=>[“pre-check=0, post-check=0, max-age=0”],
“pragma”=>[“no-cache”], “transfer-encoding”=>[“chunked”]}>