I have a nested hash like this where it can have 50 values:
{
"pool1"=>{"name"=>"my-pool", "partition"=>"Common"},
"pool2"=>{"name"=>"test-2", "partition"=>"baas"}
}
I am trying to get all of the pools with the key "partition"=>"baas"
. like this:
{"pool7"=>{"name"=>"test-7", "partition"=>"baas"}
{"pool12"=>{"name"=>"test-12", "partition"=>"baas"}
{"pool18"=>{"name"=>"test-18", "partition"=>"baas"}}
This is how i am trying to do this.
def test(partition_name,hash)
a = 1
b = partition_name
c = {}
d = 1
partition_hash.each do |i|
f = i.fetch(":pool#{a}",{}.fetch(:partition, false))
if f = b
c["pool#{d + 1}"] = i
d = d +1
end
a = a +1
end
end
I now get an error like this:
[no implicit conversion of String into Integer]
How can I solve this?