Class: Gmaps4rails::Places
- Inherits:
-
Object
- Object
- Gmaps4rails::Places
- Includes:
- BaseNetMethods
- Defined in:
- lib/gmaps4rails/api_wrappers/places.rb
Instance Attribute Summary collapse
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(lat, lng, options = {}) ⇒ Places
constructor
A new instance of Places.
Methods included from BaseNetMethods
#base_url, #checked_google_response, #parsed_response, #response, #valid_parsed_response?, #valid_response?
Constructor Details
#initialize(lat, lng, options = {}) ⇒ Places
Returns a new instance of Places.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gmaps4rails/api_wrappers/places.rb', line 10 def initialize(lat, lng, = {}) @lat, @lng = lat, lng raise_invalid unless valid_position? raise_missing_key unless [:key] [:radius] ||= 7500 [:lang] ||= "en" [:raw] ||= false [:protocol]||= "http" @options = OpenStruct.new end |
Instance Attribute Details
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
7 8 9 |
# File 'lib/gmaps4rails/api_wrappers/places.rb', line 7 def lat @lat end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng.
7 8 9 |
# File 'lib/gmaps4rails/api_wrappers/places.rb', line 7 def lng @lng end |
Instance Method Details
#get ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gmaps4rails/api_wrappers/places.rb', line 21 def get checked_google_response do return parsed_response if raw parsed_response["results"].inject([]) do |memo, result| memo << { :lat => result["geometry"]["location"]["lat"], :lng => result["geometry"]["location"]["lng"], :name => result["name"], :reference => result["reference"], :vicinity => result["vicinity"], :full_data => result } end end end |