Match a value from hash which is inside array

if result.has_key?("Value)

     p result["Value"] &&

result["#{Value}"][“query”][“location”][“data”]

end

Which will give me something like

[{“Value-1”=>“Thu Dec 20 12:41:33 EST 2012”}, {“Value-7”=>“Wed Dec 19
11:37:00 EST 2012”}, {“Value-8”=>“Sun Jan 06 12:08:58 EST 2013”}]

now from this result i want to see
if result has values like : Value-8 , then it will say “found the
result”

but i cant get my head round about how to do this.

mainly i think its a hash inside a array. and having issues
Can any one please help me

Thanks

array = [{“Value-1”=>“Thu Dec 20 12:41:33 EST 2012”}, {“Value-7”=>“Wed
Dec 19 11:37:00 EST 2012”}, {“Value-8”=>“Sun Jan 06 12:08:58 EST 2013”}]

array.each{|entry| p “found the result” if entry.include?(“Value-8”)}

On Sun, Jan 20, 2013 at 3:27 PM, robert lengu [email protected]
wrote:

if result.has_key?("Value)

     p result["Value"] &&

result[“#{Value}”][“query”][“location”][“data”]

end

Which will give me something like

No, it most likely won’t. Partly because there is a syntax error
right in the first line of the code. You also mix “Value” and
“#{Value}” which are two totally different things.

[{“Value-1”=>“Thu Dec 20 12:41:33 EST 2012”}, {“Value-7”=>“Wed Dec 19
11:37:00 EST 2012”}, {“Value-8”=>“Sun Jan 06 12:08:58 EST 2013”}]

You would need to tell us what values you have there in the Hash - if
it is a Hash at all.

now from this result i want to see
if result has values like : Value-8 , then it will say “found the
result”

Did you mean “if result has keys like ‘Value-8’”? Because you use
“Value” as key above.

but i cant get my head round about how to do this.

mainly i think its a hash inside a array. and having issues
Can any one please help me

Frankly, I am not entirely sure what you are after. If you want to
select based on keys in the Hash you could do:

result.select {|k,v| /\AValue-\d+\z/ =~ k}

Kind regards

robert