Skip to content

tonystrawberry/japan_postcoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‡―πŸ‡΅ Japan Postcoder

Tests Gem Version

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>