Class: Pumi::DataSource::Geocoder::AbstractGeocoder::AbstractProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/pumi/data_source/geocoder.rb

Direct Known Subclasses

Google, Nominatim

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(geocoder:, name:) ⇒ AbstractProvider

Returns a new instance of AbstractProvider.



23
24
25
26
# File 'lib/pumi/data_source/geocoder.rb', line 23

def initialize(geocoder:, name:)
  @geocoder = geocoder
  @name = name
end

Instance Attribute Details

#geocoderObject (readonly)

Returns the value of attribute geocoder.



21
22
23
# File 'lib/pumi/data_source/geocoder.rb', line 21

def geocoder
  @geocoder
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/pumi/data_source/geocoder.rb', line 21

def name
  @name
end

Instance Method Details

#search(term) ⇒ Object



28
29
30
31
32
# File 'lib/pumi/data_source/geocoder.rb', line 28

def search(term)
  geocoder.search(term, lookup: name).map do |result|
    build_result(result.data)
  end
end