Class: JapaneseAddressParser::Data::SinglePrefecture
- Inherits:
-
Data
- Object
- Data
- JapaneseAddressParser::Data::SinglePrefecture
- Defined in:
- lib/japanese_address_parser/data/single_prefecture.rb,
lib/japanese_address_parser/data/single_prefecture.rb,
sig/data.rbs
Overview
SinglePrefecture — api/ja.json の data 要素(都道府県+配下の市区町村一覧)。
Instance Attribute Summary collapse
-
#cities ⇒ Object
readonly
Returns the value of attribute cities.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#point ⇒ Object
readonly
Returns the value of attribute point.
-
#pref ⇒ Object
readonly
Returns the value of attribute pref.
-
#pref_k ⇒ Object
readonly
Returns the value of attribute pref_k.
-
#pref_r ⇒ Object
readonly
Returns the value of attribute pref_r.
Class Method Summary collapse
-
.from_json(hash) ⇒ SinglePrefecture
JSON(パース済み Hash・文字列キー)から VO を生成する Ruby 独自ヘルパ。.
- .new ⇒ instance
Instance Method Summary collapse
-
#prefecture_name ⇒ String
JS: prefectureName(pref) => pref.pref.
Instance Attribute Details
#cities ⇒ Object (readonly)
Returns the value of attribute cities
11 12 13 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 11 def cities @cities end |
#code ⇒ Object (readonly)
Returns the value of attribute code
11 12 13 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 11 def code @code end |
#point ⇒ Object (readonly)
Returns the value of attribute point
11 12 13 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 11 def point @point end |
#pref ⇒ Object (readonly)
Returns the value of attribute pref
11 12 13 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 11 def pref @pref end |
#pref_k ⇒ Object (readonly)
Returns the value of attribute pref_k
11 12 13 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 11 def pref_k @pref_k end |
#pref_r ⇒ Object (readonly)
Returns the value of attribute pref_r
11 12 13 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 11 def pref_r @pref_r end |
Class Method Details
.from_json(hash) ⇒ SinglePrefecture
JSON(パース済み Hash・文字列キー)から VO を生成する Ruby 独自ヘルパ。
16 17 18 19 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 16 def self.from_json(hash) cities = (hash['cities'] || []).map { |city| ::JapaneseAddressParser::Data::SingleCity.from_json(city) } new(code: hash['code'], pref: hash['pref'], pref_k: hash['pref_k'], pref_r: hash['pref_r'], point: hash['point'], cities:) end |
.new ⇒ instance
33 |
# File 'sig/data.rbs', line 33
def self.new: (code: Integer, pref: String, pref_k: String, pref_r: String, point: [Float, Float], cities: Array[SingleCity]) -> instance
|
Instance Method Details
#prefecture_name ⇒ String
JS: prefectureName(pref) => pref.pref
22 23 24 |
# File 'lib/japanese_address_parser/data/single_prefecture.rb', line 22 def prefecture_name pref end |