On Sun, Dec 9, 2012 at 2:21 PM, Ferdous ara <[email protected]> wrote:
> may be i need to design my logic in a different way
> let me explain
>
> basically in that hash table (out put of JSON)
>
> as key => value
>
>
>
> i got like this
> [
> {
> "notes_expanded" : "check_maintanance_mode",
> "host_comments" : [],
> "host_icon_image_expanded" : "",
> "checks_enabled" : 1,
> "max_check_attempts" : 3,
> "host" : service2.home.lan,
>
> }
> {
> "notes_expanded" : "check_memory ",
> "host_comments" : [],
> "host_icon_image_expanded" : "",
> "checks_enabled" : 1,
> "max_check_attempts" : 3,
> "host" : service.home.lan,
>
> }
> {
> "notes_expanded" : "check_maintanance_mode",
> "host_comments" : [],
> "host_icon_image_expanded" : "",
> "checks_enabled" : 1,
> "max_check_attempts" : 3,
> "host" : service.home.lan,
>
> }
> ]
>
> So Basically i want to get all the host which
> notes_expanded = check_maintanance_mode
> so i should get only 2
>
> Does it make sense ??
Yes, but it's something completely different than selecting from a
Hash based on values. You rather want something like
items = stuff.select {|h| h["notes_expanded"] == "check_maintanance_mode"}
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en