Class: JapaneseAddressParser::City

Inherits:
Data
  • Object
show all
Defined in:
lib/japanese_address_parser/city.rb,
lib/japanese_address_parser/city.rb,
sig/address.rbs

Overview

市区町村のリッチ VO。name は cityName(郡+市+政令区)。point は代表点(NormalizeResultPoint, level 2)。

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



11
12
13
# File 'lib/japanese_address_parser/city.rb', line 11

def code
  @code
end

#countyObject (readonly)

Returns the value of attribute county

Returns:

  • (Object)

    the current value of county



11
12
13
# File 'lib/japanese_address_parser/city.rb', line 11

def county
  @county
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



11
12
13
# File 'lib/japanese_address_parser/city.rb', line 11

def name
  @name
end

#name_kanaObject (readonly)

Returns the value of attribute name_kana

Returns:

  • (Object)

    the current value of name_kana



11
12
13
# File 'lib/japanese_address_parser/city.rb', line 11

def name_kana
  @name_kana
end

#name_romajiObject (readonly)

Returns the value of attribute name_romaji

Returns:

  • (Object)

    the current value of name_romaji



11
12
13
# File 'lib/japanese_address_parser/city.rb', line 11

def name_romaji
  @name_romaji
end

#pointObject (readonly)

Returns the value of attribute point

Returns:

  • (Object)

    the current value of point



11
12
13
# File 'lib/japanese_address_parser/city.rb', line 11

def point
  @point
end

#wardObject (readonly)

Returns the value of attribute ward

Returns:

  • (Object)

    the current value of ward



11
12
13
# File 'lib/japanese_address_parser/city.rb', line 11

def ward
  @ward
end

Class Method Details

.from_metadata(city) ⇒ City?

metadata.city(SingleCity VO)から VO を作る。city 未判別なら nil。

Parameters:

Returns:



16
17
18
19
20
# File 'lib/japanese_address_parser/city.rb', line 16

def self.(city)
  return if city.nil?

  new(name: city.city_name, code: city.code, county: city.county, ward: city.ward, name_kana: city.city_k, name_romaji: city.city_r, point: ResultPoint.city_to_result_point(city))
end

.newinstance

Parameters:

  • name: (String)
  • code: (Integer)
  • county: (String, nil)
  • ward: (String, nil)
  • name_kana: (String)
  • name_romaji: (String)
  • point: (NormalizeResultPoint)

Returns:

  • (instance)


26
# File 'sig/address.rbs', line 26

def self.new: (name: String, code: Integer, county: String?, ward: String?, name_kana: String, name_romaji: String, point: NormalizeResultPoint) -> instance

Instance Method Details

#to_hHash[Symbol, untyped]

緯度経度をネストも含めて Hash 化する Ruby 独自 API。

Returns:

  • (Hash[Symbol, untyped])


23
24
25
# File 'lib/japanese_address_parser/city.rb', line 23

def to_h
  { name:, code:, county:, ward:, name_kana:, name_romaji:, point: point.to_h }
end