Your'e looking at the result in correctly,-- that is not a comment in the 
array! Its the "stringified" output of the array that contains Geocoder::Result 
objects.

res = Geocoder.search(addy1).first

res.data   # => gives you entire data .. seen as @data and then you can 
traverse as a hash

There are other helper routines too (a few mentioned below).
res.address
res.city
res.state
res.formatted_address
res.coordinates 

etc. See these two files to learn all the methods of Geocoder::Result 
https://github.com/alexreisner/geocoder/blob/master/lib/geocoder/results/google.rb
 
https://github.com/alexreisner/geocoder/blob/master/lib/geocoder/results/base.rb

Cheers!
@gautamrege
~~~~~~~~~~~~~~~
All wiyht. Rho sritched mg kegtops awound?

On 06-Feb-2014, at 8:23 am, BeeRich <[email protected]> wrote:

> I have the following instruction that returns an array that I'm quite 
> confused about.  I can't even read it.  Can someone shed some light as to how 
> to reach into this array of hashes (that's what I can see) to get the 
> location lat and lon?
> 
> res = Geocoder.search(addy1)
> 
> This is the res:
> 
> [#<Geocoder::Result::Google:0x007fb46c345e18 
> @data={"address_components"=>[{"long_name"=>"1600", "short_name"=>"1600", 
> "types"=>["street_number"]}, {"long_name"=>"Amphitheatre Parkway", 
> "short_name"=>"Amphitheatre Pkwy", "types"=>["route"]}, 
> {"long_name"=>"Mountain View", "short_name"=>"Mountain View", 
> "types"=>["locality", "political"]}, {"long_name"=>"California", 
> "short_name"=>"CA", "types"=>["administrative_area_level_1", "political"]}, 
> {"long_name"=>"United States", "short_name"=>"US", "types"=>["country", 
> "political"]}, {"long_name"=>"94043", "short_name"=>"94043", 
> "types"=>["postal_code"]}], "formatted_address"=>"1600 Amphitheatre Parkway, 
> Mountain View, CA 94043, USA", "geometry"=>{"location"=>{"lat"=>37.4219985, 
> "lng"=>-122.0839544}, "location_type"=>"ROOFTOP", 
> "viewport"=>{"northeast"=>{"lat"=>37.4233474802915, 
> "lng"=>-122.0826054197085}, "southwest"=>{"lat"=>37.4206495197085, 
> "lng"=>-122.0853033802915}}}, "types"=>["street_address"]}, @cache_hit=nil>]
> 
> Outside of the conversion of string to integer errors (?), I can't traverse 
> this array because it holds a comment in the first line there, before an 
> instance variable is set to the data.  Quite confused.  Any insight 
> appreciated.
> 
> Cheers
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/BF85B3A3-F060-4E41-94B8-0FA71259AC28%40gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/8B67D434-8BEB-4E4D-9B06-33ED5F7EA8B9%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to