Module: ZipCodeJp
- Defined in:
- lib/zip_code_jp.rb,
lib/zip_code_jp/export.rb,
lib/zip_code_jp/address.rb,
lib/zip_code_jp/version.rb
Defined Under Namespace
Constant Summary collapse
- DATA_DIR =
File.dirname(__FILE__) + '/../data'
- VERSION =
'0.0.2'
Class Method Summary collapse
Class Method Details
.export_json ⇒ Object
10 11 12 |
# File 'lib/zip_code_jp.rb', line 10 def export_json ZipCodeJp::Export.execute end |
.find(zip_code) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zip_code_jp.rb', line 14 def find(zip_code) zip_code = zip_code.gsub(/-/, '') json_file = DATA_DIR + '/zip_code/' + zip_code.slice(0,3) + '.json' if (File.exists?(json_file)) data = JSON.parse(File.open(json_file).read) address_data = data[zip_code.slice(3,4)] return address_data ? ZipCodeJp::Address.new(address_data) : false end return false end |