Class: JapaneseAddressParser::NormalizeResultPoint
- Inherits:
-
Data
- Object
- Data
- JapaneseAddressParser::NormalizeResultPoint
- Defined in:
- lib/japanese_address_parser/normalize_result_point.rb,
lib/japanese_address_parser/normalize_result_point.rb,
sig/normalize_result_point.rbs
Overview
正規化結果の位置情報(EPSG:4326 / WGS84)。level は座標の正確さ(1:県 2:市 3:町字 8:住居表示/地番)。
Instance Attribute Summary collapse
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
Class Method Summary collapse
-
.from_lng_lat(point, level:) ⇒ Object
Ruby 独自の補助コンストラクタ: [lng, lat] 配列(無ければ nil)から VO を作る。 上流 types.ts の *ToResultPoint は VO の .point を直接受けるため逐語移植のまま残し、 metadata の Hash([lng, lat] 配列)から組み立てるリッチ VO 層はこのファクトリを共有する。.
- .new ⇒ instance
-
.normalize_result_point?(obj) ⇒ Boolean
JS: isNormalizeResultPoint(obj) — 任意の値が NormalizeResultPoint の形か検証する type guard。 JS は object のプロパティ存在+数値型を見る。Ruby では lat/lng/level に応答し、それらが Numeric かつ level が 1/2/3/8 のいずれか、で判定する(JS↔Ruby のオブジェクトモデル差のため Hash は対象外=working_agreement §3-4。挙動は spec に固定する)。.
Instance Method Summary collapse
Instance Attribute Details
#lat ⇒ Object (readonly)
Returns the value of attribute lat
9 10 11 |
# File 'lib/japanese_address_parser/normalize_result_point.rb', line 9 def lat @lat end |
#level ⇒ Object (readonly)
Returns the value of attribute level
9 10 11 |
# File 'lib/japanese_address_parser/normalize_result_point.rb', line 9 def level @level end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng
9 10 11 |
# File 'lib/japanese_address_parser/normalize_result_point.rb', line 9 def lng @lng end |
Class Method Details
.from_lng_lat(point, level:) ⇒ NormalizeResultPoint .from_lng_lat(point, level:) ⇒ nil .from_lng_lat(point, level:) ⇒ NormalizeResultPoint?
Ruby 独自の補助コンストラクタ: [lng, lat] 配列(無ければ nil)から VO を作る。 上流 types.ts の *ToResultPoint は VO の .point を直接受けるため逐語移植のまま残し、 metadata の Hash([lng, lat] 配列)から組み立てるリッチ VO 層はこのファクトリを共有する。
16 17 18 19 20 |
# File 'lib/japanese_address_parser/normalize_result_point.rb', line 16 def self.from_lng_lat(point, level:) return if point.nil? new(lat: point[1], lng: point[0], level:) end |
.new ⇒ instance
8 |
# File 'sig/normalize_result_point.rbs', line 8
def self.new: (lat: Float, lng: Float, level: Integer) -> instance
|
.normalize_result_point?(obj) ⇒ Boolean
JS: isNormalizeResultPoint(obj) — 任意の値が NormalizeResultPoint の形か検証する type guard。 JS は object のプロパティ存在+数値型を見る。Ruby では lat/lng/level に応答し、それらが Numeric かつ level が 1/2/3/8 のいずれか、で判定する(JS↔Ruby のオブジェクトモデル差のため Hash は対象外=working_agreement §3-4。挙動は spec に固定する)。
26 27 28 29 30 31 |
# File 'lib/japanese_address_parser/normalize_result_point.rb', line 26 def self.normalize_result_point?(obj) return false unless obj.respond_to?(:lat) && obj.respond_to?(:lng) && obj.respond_to?(:level) return false unless obj.lat.is_a?(::Numeric) && obj.lng.is_a?(::Numeric) && obj.level.is_a?(::Numeric) [1, 2, 3, 8].include?(obj.level) # JS: validLevels = [1, 2, 3, 8] end |
Instance Method Details
#to_h ⇒ Hash[Symbol, untyped]
13 |
# File 'sig/normalize_result_point.rbs', line 13
def to_h: () -> Hash[Symbol, untyped]
|