JpPrefecture
日本の都道府県データを検索できる Elixir ライブラリです。
Installation
If available in Hex, the package can be installed
by adding jp_prefecture to your list of dependencies in mix.exs:
def deps do
[
{:jp_prefecture, "~> 0.1.0"}
]
end
Basic Usage
# すべての都道府県を取得
JpPrefecture.all()
# ID から取得
JpPrefecture.find(13)
JpPrefecture.find(code: 13)
# 日本語名または英語名から取得
JpPrefecture.find(name: "東京")
JpPrefecture.find(name: "tokyo")
# 地域から検索
JpPrefecture.where(area: "関東")
# 都道府県名から検索(部分一致)
JpPrefecture.where(name: "東京")
JpPrefecture.where(name: "tok")
# ID のリストから検索
JpPrefecture.where(id: [1, 13, 47])
find(name: ...) は一致した最初の都道府県を返し、該当しない場合は nil を返します。where(...) は一致した都道府県をリストで返します。
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/jp_prefecture.