Class: Worldwide::RegionsLoader
- Inherits:
-
Object
- Object
- Worldwide::RegionsLoader
- Defined in:
- lib/worldwide/regions_loader.rb
Constant Summary collapse
- WORLD_CODE =
UN code for the whole world
"001"
Instance Method Summary collapse
Instance Method Details
#load_regions ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/worldwide/regions_loader.rb', line 11 def load_regions @regions_by_cldr_code = {} @regions_by_iso_code = {} # Load country/region definitions out of the db/data/regions/??.yml files @regions = Dir["#{Worldwide::Paths::REGIONS_ROOT}/*.yml"].map do |filename| load_territory(filename) end.flatten # Load hierarchies out of world.yml, and construct regions to match the specified hierarchies apply_hierarchy(parent: nil, code: WORLD_CODE, children: world_yml[WORLD_CODE]) world_yml["alternates"].each do |code, children| apply_hierarchy(parent: nil, code: code, children: children) end # Construct regions to represent trading blocks like the EU construct_trading_blocks construct_unknown @regions.each do |region| construct_lookup_info(region) end [@regions.freeze, @regions_by_cldr_code, @regions_by_iso_code] end |