Class: UkCountyLocator::PolygonFetcher
- Inherits:
-
Object
- Object
- UkCountyLocator::PolygonFetcher
- Defined in:
- lib/uk_county_locator/polygon_fetcher.rb
Overview
The ‘UkCountyLocator::PolygonFetcher` retrieves geographic polygon data for UK counties. Supports `:current`, `:ceremonial`, and `:historic` county types. The class supports a large number of aliases for each county, stored in the aliases directory.
Instance Method Summary collapse
- #county_list ⇒ Object
- #county_polygon(county) ⇒ Object
-
#initialize(type:) ⇒ PolygonFetcher
constructor
A new instance of PolygonFetcher.
Constructor Details
#initialize(type:) ⇒ PolygonFetcher
Returns a new instance of PolygonFetcher.
15 16 17 18 |
# File 'lib/uk_county_locator/polygon_fetcher.rb', line 15 def initialize(type:) @type = type @counties = fetch_county_polygons.transform_keys(&:downcase) end |
Instance Method Details
#county_list ⇒ Object
28 29 30 |
# File 'lib/uk_county_locator/polygon_fetcher.rb', line 28 def county_list fetch_county_polygons.keys.sort end |
#county_polygon(county) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/uk_county_locator/polygon_fetcher.rb', line 20 def county_polygon(county) county = county.downcase return @counties[county] if @counties[county] return @counties[county_by_alias(county)] if @counties[county_by_alias(county)] nil end |