π―π΅ Japan Postcoder
Japan Postcoder is a library that allows you to get the address of a location in Japan from its postcode. It will help you get the prefecture, city, ward and street name from a postcode.
All the location data is provided by the Japan Post
Rubygems link is here: https://rubygems.org/gems/japan_postcoder
ππ» Getting started
Start by including japan-postcoder in your project:
gem 'japan-postcoder'
Then, you can use the JapanPostcoder class to get the address of a location in Japan from its postcode:
π¨π»βπ» Usage
You can use the JapanPostcoder class to get the address of a location in Japan in string format.
require 'japan-postcoder'
postcode = '2140037'
address = JapanPostcoder.to_address(postcode)
puts address # => "η₯ε₯ε·ηε·ε΄εΈε€ζ©εΊθ
δ»θ°·ηΊ"
You can also use the JapanPostcoder class to get the address of a location in Japan in hash format.
require 'japan-postcoder'
postcode = '2140037'
address = JapanPostcoder.to_address_hash(postcode)
puts address # => {:prefecture=>"η₯ε₯ε·η", :city=>"ε·ε΄εΈ", :ward=>"ε€ζ©εΊ", :district=>"θ
δ»θ°·ηΊ"}
π¬π§ Romaji transcription
You can use the JapanPostcoder class to get the address of a location in Japan in romaji format by using the romaji named argument.
address = JapanPostcoder.to_address('2140037', romaji: true)
puts address # => "KANAGAWA KEN KAWASAKI SHI TAMA KU SUGESEN YACHO"
address = JapanPostcoder.to_address_hash('2140037', romaji: true)
puts address # => {:prefecture=>"KANAGAWA KEN", :city=>"KAWASAKI SHI", :ward=>"TAMA KU", :district=>"SUGESEN YACHO"}
πͺ Contributing
If you notice a bug or want to add a new feature, please open an issue or submit a pull request. Thank you and enjoy!
π License
This project is free to use under the terms of the MIT License.
π Self-memo
After updating the gem:
- Update the version in
lib/japan_postcoder/version.rb - Create a PR and merge it after it's been approved & tested
- Run
gem build japan_postcoder.gemspec - Run
gem push japan_postcoder-<version>.gem - Run
gh release create <version>