I am trying out the geocoder gem and looking to acceess the viewport results.
Being new to Ruby is there a better way to access the result.
result = Geocoder.search("New York, NY").map(&:geometry)
north_east_lat = result[0]["viewport"]["northeast"]["lat"]
north_east_lng = result[0]["viewport"]["northeast"]["lng"]
While this does work it looks ugly and brittle
Any advise on making this better?
As far as I see,
geometrydata is just a simpleHash. If you don’t like the way you have to access values by [“key”] at multiple levels, you can convert Hash to OpenStruct.