Module: RegionArea

Overview

Define the region area mappings in a field called +prefixes+.

Example: include RegionArea def initialize super @prefixes = { 'us' => 'US', 'eu' => 'EU', } end

Constant Summary collapse

UNKNOWN =
'UNKNOWN'

Instance Method Summary collapse

Instance Method Details

#extract_region_area(region) ⇒ Object


14
15
16
17
18
19
20
# File 'app/lib/region_area.rb', line 14

def extract_region_area(region)
  @prefixes.each do |prefix, region_area|
    return region_area if region.start_with?(prefix)
  end
  puts "WARNING: Could not match region `#{region}` to a region area. Check `PREFIXES` in `#{self.class}`!"
  UNKNOWN
end