Class: Locator
- Inherits:
-
Object
- Object
- Locator
- Defined in:
- lib/meteorologist/locator.rb
Constant Summary collapse
- GEOCODE_URL =
'https://maps.googleapis.com/maps/api/geocode'
Instance Method Summary collapse
- #coordinates ⇒ Object
-
#initialize(location, options = {}) ⇒ Locator
constructor
A new instance of Locator.
- #name ⇒ Object
- #write_to_cache ⇒ Object
Constructor Details
#initialize(location, options = {}) ⇒ Locator
Returns a new instance of Locator.
5 6 7 8 9 10 |
# File 'lib/meteorologist/locator.rb', line 5 def initialize(location, = {}) data = .fetch(:data) { get_data_from_api(location) } @location = location @navigation_data = validate_and_parse(data) @cache_class = .fetch(:cache_class) { LocationCache } end |
Instance Method Details
#coordinates ⇒ Object
12 13 14 |
# File 'lib/meteorologist/locator.rb', line 12 def coordinates "#{geometry['location']['lat']},#{geometry['location']['lng']}" end |
#name ⇒ Object
16 17 18 |
# File 'lib/meteorologist/locator.rb', line 16 def name ['formatted_address'] end |
#write_to_cache ⇒ Object
20 21 22 |
# File 'lib/meteorologist/locator.rb', line 20 def write_to_cache @cache_class.write(location, attributes_for_cache) end |