class SuperZipcode::Taiwan
Constants
- CITY_ZONE_ZIP_CODES
Public Class Methods
code_regex()
click to toggle source
# File lib/super_zipcode/taiwan.rb, line 108 def self.code_regex /(.{0,2}市|.{0,2}縣)(新市區|左鎮區|平鎮區|釣魚台列嶼|東沙群島|南沙群島|那瑪夏區|.{0,2}區|.{0,3}鄉|.{0,2}鎮|.{0,2}市)/ end
find_city(address)
click to toggle source
# File lib/super_zipcode/taiwan.rb, line 123 def self.find_city(address) regex_match = code_regex =~ address return nil if regex_match.blank? city = $1 CITY_ZONE_ZIP_CODES[city].present? && city end
find_zip_code(address)
click to toggle source
# File lib/super_zipcode/taiwan.rb, line 112 def self.find_zip_code(address) regex_match = code_regex =~ address return nil if regex_match.blank? city = $1 district = $2 return nil if CITY_ZONE_ZIP_CODES[city].blank? CITY_ZONE_ZIP_CODES[city][district] end