Hi, i am using countries gem for my application i what state in particuller which comes like {"RK"=>{"name"=>"Ra’s al Khaymah", "names"=>"Ra’s al Khaymah"}, "AZ"=>{"name"=>"Abu Z¸aby [Abu Dhabi]", "names"=>["Abu Zabi", "Abu Zaby", "Ab\xC5\xAB Z\xCC\xA8ab\xC4\xAB", "Abu Dhabi", "Abu Dhabi"]}, "FU"=>{"name"=>"Al Fujayrah", "names"=>"Al Fujayrah"}, "UQ"=>{"name"=>"Umm al Qaywayn", "names"=>"Umm al Qaywayn"}, "DU"=>{"name"=>"Dubayy [Dubai]", "names"=>"Dubayy [Dubai]"}, "AJ"=>{"name"=>"''Ajman", "names"=>["Ujman"]}, "SH"=>{"name"=>"Ash Shariqah [Sharjah]", "names"=>"Ash Shariqah [Sharjah]"}} i need value of name alone in this array that is only state name how to get this? thanks, -pab -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Oct-22 07:52 UTC
Re: how to split particuller value from an array in countries gem
On 22 October 2011 08:15, Pab <prabu.net88-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > > i am using countries gem for my application i what state in > particuller which comes like > > {"RK"=>{"name"=>"Ra’s al Khaymah", "names"=>"Ra’s al Khaymah"}, > "AZ"=>{"name"=>"Abu Z¸aby [Abu Dhabi]", "names"=>["Abu Zabi", "Abu > Zaby", "Ab\xC5\xAB Z\xCC\xA8ab\xC4\xAB", "Abu Dhabi", "Abu Dhabi"]}, > "FU"=>{"name"=>"Al Fujayrah", "names"=>"Al Fujayrah"}, > "UQ"=>{"name"=>"Umm al Qaywayn", "names"=>"Umm al Qaywayn"}, > "DU"=>{"name"=>"Dubayy [Dubai]", "names"=>"Dubayy [Dubai]"}, > "AJ"=>{"name"=>"''Ajman", "names"=>["Ujman"]}, "SH"=>{"name"=>"Ash > Shariqah [Sharjah]", "names"=>"Ash Shariqah [Sharjah]"}} > > > i need value of name alone in this array that is only state name how > to get this?I think you need to ask the question again, it is not clear what you are trying to achieve. To start with the data you have shown appears to be a hash not an array. So presumably you have this hash in a variable and are trying to extract something from it. Tell us in more detail what you want to get out, not just in words, show us an example of what you are trying to achieve. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ray Parker
2011-Oct-22 14:18 UTC
Re: how to split particuller value from an array in countries gem
array_of_names = my_original_hash.collect{|key, value| value["name"]} On Oct 22, 3:15 am, Pab <prabu.ne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > i am using countries gem for my application i what state in > particuller which comes like > > {"RK"=>{"name"=>"Ra’s al Khaymah", "names"=>"Ra’s al Khaymah"}, > "AZ"=>{"name"=>"Abu Z¸aby [Abu Dhabi]", "names"=>["Abu Zabi", "Abu > Zaby", "Ab\xC5\xAB Z\xCC\xA8ab\xC4\xAB", "Abu Dhabi", "Abu Dhabi"]}, > "FU"=>{"name"=>"Al Fujayrah", "names"=>"Al Fujayrah"}, > "UQ"=>{"name"=>"Umm al Qaywayn", "names"=>"Umm al Qaywayn"}, > "DU"=>{"name"=>"Dubayy [Dubai]", "names"=>"Dubayy [Dubai]"}, > "AJ"=>{"name"=>"''Ajman", "names"=>["Ujman"]}, "SH"=>{"name"=>"Ash > Shariqah [Sharjah]", "names"=>"Ash Shariqah [Sharjah]"}} > > i need value of name alone in this array that is only state name how > to get this? > > thanks, > -pab-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.