Sha256: 58aa4047f6b6050230038daff7caa255ad365a46bbb5417d8f182b01dc1a60dd
Contents?: true
Size: 585 Bytes
Versions: 1
Compression:
Stored size: 585 Bytes
Contents
# coding: utf-8 require 'yaml' module JpPrefecture # コードと都道府県のマッピング module ZipMapping filepath = File.join(File.dirname(__FILE__), '../../data/zip.yml') @data = YAML.load_file(filepath) @data = Hash[*@data.collect{|code, arr|[code, arr.collect{|zip_from, zip_to|zip_from..zip_to}]}.flatten(1)] def self.data JpPrefecture.config.zip_mapping_data || @data end def self.code_for_zip zip self.data.select do |code, zip_ranges| zip_ranges.find{|range|range.include? zip} end.keys.first end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jp_prefecture-0.5.0 | lib/jp_prefecture/zip_mapping.rb |