Sha256: 0cd298b0fc5777aeecea18c6997aba77836d6d180bdca8a0ff54aec0ac735f46

Contents?: true

Size: 922 Bytes

Versions: 11

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

require_relative 'japanese_address_parser/address_normalizer'
require_relative 'japanese_address_parser/address_parser'
require_relative 'japanese_address_parser/version'

module JapaneseAddressParser
  def call(full_address)
    _call(full_address)
  rescue ::JapaneseAddressParser::NormalizeError
    nil
  end

  def call!(full_address)
    _call(full_address)
  end

  def _call(full_address)
    normalized = ::JapaneseAddressParser::AddressNormalizer.call(full_address)

    # このライブラリで探索するのは町域まで。
    # それ以降のデータを使って探索するとデータと名前が一致しないことがあるので、町域までのデータを使う。
    ::JapaneseAddressParser::AddressParser.call("#{normalized['pref']}#{normalized['city']}#{normalized['town']}")
  end

  module_function :call, :call!, :_call
  private_class_method :_call
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
japanese_address_parser-3.1.2 lib/japanese_address_parser.rb
japanese_address_parser-3.1.1 lib/japanese_address_parser.rb
japanese_address_parser-3.1.0 lib/japanese_address_parser.rb
japanese_address_parser-3.0.5 lib/japanese_address_parser.rb
japanese_address_parser-3.0.4 lib/japanese_address_parser.rb
japanese_address_parser-3.0.3 lib/japanese_address_parser.rb
japanese_address_parser-3.0.2 lib/japanese_address_parser.rb
japanese_address_parser-3.0.1 lib/japanese_address_parser.rb
japanese_address_parser-3.0.0 lib/japanese_address_parser.rb
japanese_address_parser-2.2.1 lib/japanese_address_parser.rb
japanese_address_parser-2.2.0 lib/japanese_address_parser.rb