Class: JapaneseAddressParser::Address
- Inherits:
-
Data
- Object
- Data
- JapaneseAddressParser::Address
- Defined in:
- lib/japanese_address_parser/address.rb,
lib/japanese_address_parser/address.rb,
sig/address.rbs
Overview
正規化結果の公開 VO。prefecture/city/town は未判別なら nil(JS 同様、未マッチは失敗ではない)。 metadata は VO に昇格しない生データ(rsdt/chiban 等)の逃がし道(working_agreement §1-3)。
Instance Attribute Summary collapse
-
#addr ⇒ Object
readonly
Returns the value of attribute addr.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#full_address ⇒ Object
readonly
Returns the value of attribute full_address.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#other ⇒ Object
readonly
Returns the value of attribute other.
-
#point ⇒ Object
readonly
Returns the value of attribute point.
-
#prefecture ⇒ Object
readonly
Returns the value of attribute prefecture.
-
#town ⇒ Object
readonly
Returns the value of attribute town.
Class Method Summary collapse
-
.from_normalize_result(result) ⇒ Address
内部 NormalizeResult から公開 Address を組み立てる。.
- .new ⇒ instance
Instance Method Summary collapse
-
#to_h ⇒ Hash[Symbol, untyped]
ネストした VO・座標も含めて Hash 化する Ruby 独自 API。metadata は生データの逃がし道として shallow に Hash 化する(内部の SingleCity 等は VO のまま)。.
Instance Attribute Details
#addr ⇒ Object (readonly)
Returns the value of attribute addr
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def addr @addr end |
#city ⇒ Object (readonly)
Returns the value of attribute city
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def city @city end |
#full_address ⇒ Object (readonly)
Returns the value of attribute full_address
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def full_address @full_address end |
#level ⇒ Object (readonly)
Returns the value of attribute level
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def level @level end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def @metadata end |
#other ⇒ Object (readonly)
Returns the value of attribute other
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def other @other end |
#point ⇒ Object (readonly)
Returns the value of attribute point
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def point @point end |
#prefecture ⇒ Object (readonly)
Returns the value of attribute prefecture
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def prefecture @prefecture end |
#town ⇒ Object (readonly)
Returns the value of attribute town
14 15 16 |
# File 'lib/japanese_address_parser/address.rb', line 14 def town @town end |
Class Method Details
.from_normalize_result(result) ⇒ Address
内部 NormalizeResult から公開 Address を組み立てる。
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/japanese_address_parser/address.rb', line 19 def self.from_normalize_result(result) = result. new( full_address: .input, prefecture: Prefecture.(.prefecture), city: City.(.city), town: Town.(.machi_aza), addr: result.addr, other: result.other, point: result.point, level: result.level, metadata: ) end |
.new ⇒ instance
55 |
# File 'sig/address.rbs', line 55
def self.new: (full_address: String, prefecture: Prefecture?, city: City?, town: Town?, addr: String?, other: String, point: NormalizeResultPoint?, level: Integer, metadata: NormalizeResultMetadata) -> instance
|
Instance Method Details
#to_h ⇒ Hash[Symbol, untyped]
ネストした VO・座標も含めて Hash 化する Ruby 独自 API。metadata は生データの逃がし道として shallow に Hash 化する(内部の SingleCity 等は VO のまま)。
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/japanese_address_parser/address.rb', line 36 def to_h { full_address:, prefecture: prefecture&.to_h, city: city&.to_h, town: town&.to_h, addr:, other:, point: point&.to_h, level:, metadata: .to_h } end |