Forum: Ruby-Forum.com Parsing a List result - Ruby

B46cf7a3b580f672bfb8b8e2aed6d6f1?d=identicon&s=25 Fernando Ramos (ramosbrazil)
on 2009-01-19 03:32
Hi Folks,

I need to parse a result that comes in this format :

=========================
 ec2.describe_instances #=>
   [{:aws_image_id       => "ami-e444444d",
     :aws_reason         => "",
     :aws_state_code     => "16",
     :aws_owner          => "000000000888",
     :aws_instance_id    => "i-123f1234",
     :aws_reservation_id => "r-aabbccdd",
     :aws_state          => "running",
     :dns_name           =>
"domU-12-34-67-89-01-C9.usma2.compute.amazonaws.com",
     :ssh_key_name       => "staging",
     :aws_groups         => ["default"],
     :private_dns_name   =>
"domU-12-34-67-89-01-C9.usma2.compute.amazonaws.com",
     :aws_instance_type  => "m1.small",
     :aws_launch_time    => "2008-1-1T00:00:00.000Z"},
     :aws_availability_zone => "us-east-1b",
     :aws_kernel_id      => "aki-ba3adfd3",
     :aws_ramdisk_id     => "ari-badbad00",
      ..., {...}]
=========================

When I invoke the method,

puts @ec2.describe_instances

the results comes like this :
=========================
aws_image_idami-e444444daws_reasonaws_state_codeaws_owner000000000888aws_instance_id
i-123f1234aws_reservation_idr-aabbccddaws_staterunningdns_name
domU-12-34-67-89-01-C9.usma2.compute.amazonaws.comssh_key_namestagingaws_groups
...
=========================
Question :

Is there a way of accessing a specific key, for example : aws_status ?
If so, how do I do that ?

Thank you so much.

Regards.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.