I have a hash in ruby which looks something like this:
{
\"admin_milestones\"=>\"1\",
\"users_milestones\"=>\"0\",
\"admin_goals\"=>\"1\",
\
Just Hash.select
:
h1.select { |key, value| value == '0' } #=> {"users_milestones"=>"0", "users_goals"=>"0", ...}
h1.select { |key, value| value == '1' } #=> {"admin_milestones"=>"1", "admin_goals"=>"1", ...}
The return value depends on your Ruby version. Ruby 1.8 returns a array of arrays, whereas Ruby 1.9 returns a hash like in the example above.