Class: JapaneseAddressParser::Prefecture

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

Overview

都道府県のリッチ VO。point は代表点(NormalizeResultPoint, level 1)。

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/prefecture.rb', line 11

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



11
12
13
# File 'lib/japanese_address_parser/prefecture.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/prefecture.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/prefecture.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/prefecture.rb', line 11

def point
  @point
end

Class Method Details

.from_metadata(hash) ⇒ Prefecture?

metadata.prefecture(cities を除いた Hash・Symbol キー)から VO を作る。pref 未判別なら nil。 point(level 1 代表点)は都道府県データに必ず存在する(from_lng_lat は nil 受けも安全)。

Parameters:

  • hash (Hash[Symbol, untyped], nil)

Returns:



17
18
19
20
21
# File 'lib/japanese_address_parser/prefecture.rb', line 17

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

  new(name: hash[:pref], code: hash[:code], name_kana: hash[:pref_k], name_romaji: hash[:pref_r], point: NormalizeResultPoint.from_lng_lat(hash[:point], level: 1))
end

.newinstance

Parameters:

  • name: (String)
  • code: (Integer)
  • name_kana: (String)
  • name_romaji: (String)
  • point: (NormalizeResultPoint)

Returns:

  • (instance)


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

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

Instance Method Details

#to_hHash[Symbol, untyped]

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

Returns:

  • (Hash[Symbol, untyped])


24
25
26
# File 'lib/japanese_address_parser/prefecture.rb', line 24

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