Module: UKPostcode::CountryFinder

Defined in:
lib/uk_postcode/country_finder.rb

Class Method Summary collapse

Class Method Details

.country(postcode) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/uk_postcode/country_finder.rb', line 7

def country(postcode)
  normalized = [postcode.outcode, postcode.incode].compact.join
  COUNTRY_LOOKUP.each do |name, regexp|
    return name if normalized.match(regexp)
  end
  :unknown
end