Module: JapaneseAddressParser::Utils

Defined in:
lib/japanese_address_parser/utils.rb,
sig/utils.rbs

Overview

出力 metadata 用に、VO から余分なフィールドを取り除いたコピー(Hash)を作る。

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.remove_cities_from_prefecture(pref) ⇒ Object

JS: removeCitiesFromPrefecture(pref) if (!pref) return undefined const newPref = { ...pref }; delete newPref.cities; return newPref Data.define はフィールドを削除できないので、to_h でキー付き Hash 化してから cities キーを除く(JS の Omit<SinglePrefecture, 'cities'> 相当)。



16
17
18
19
20
21
22
# File 'lib/japanese_address_parser/utils.rb', line 16

def remove_cities_from_prefecture(pref)
  return if pref.nil?

  hash = pref.to_h
  hash.delete(:cities)
  hash
end

.remove_extra_from_machi_aza(machi_aza) ⇒ Object

JS: removeExtraFromMachiAza(machiAza) if (!machiAza) return undefined const newMachiAza = { ...machiAza }; delete newMachiAza.csv_ranges; return newMachiAza



27
28
29
30
31
32
33
# File 'lib/japanese_address_parser/utils.rb', line 27

def remove_extra_from_machi_aza(machi_aza)
  return if machi_aza.nil?

  hash = machi_aza.to_h
  hash.delete(:csv_ranges)
  hash
end

Instance Method Details

#self?.remove_cities_from_prefectureHash[Symbol, untyped]?

Parameters:

  • pref (Object)

Returns:

  • (Hash[Symbol, untyped], nil)


4
# File 'sig/utils.rbs', line 4

def self?.remove_cities_from_prefecture: (untyped pref) -> (Hash[Symbol, untyped] | nil)

#self?.remove_extra_from_machi_azaHash[Symbol, untyped]?

Parameters:

  • machi_aza (Object)

Returns:

  • (Hash[Symbol, untyped], nil)


5
# File 'sig/utils.rbs', line 5

def self?.remove_extra_from_machi_aza: (untyped machi_aza) -> (Hash[Symbol, untyped] | nil)