Class: JapaneseAddressParser::Data::SingleCity
- Inherits:
-
Data
- Object
- Data
- JapaneseAddressParser::Data::SingleCity
- Defined in:
- lib/japanese_address_parser/data/single_city.rb,
lib/japanese_address_parser/data/single_city.rb,
sig/data.rbs
Overview
SingleCity — api/ja.json の cities 要素(政令市の場合は区で区切られる)。
::Data.define(先頭 :: は名前空間 JapaneseAddressParser::Data 内で
トップレベル定数 ::Data を指すために必須)。
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#city_k ⇒ Object
readonly
Returns the value of attribute city_k.
-
#city_r ⇒ Object
readonly
Returns the value of attribute city_r.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#county ⇒ Object
readonly
Returns the value of attribute county.
-
#county_k ⇒ Object
readonly
Returns the value of attribute county_k.
-
#county_r ⇒ Object
readonly
Returns the value of attribute county_r.
-
#point ⇒ Object
readonly
Returns the value of attribute point.
-
#ward ⇒ Object
readonly
Returns the value of attribute ward.
-
#ward_k ⇒ Object
readonly
Returns the value of attribute ward_k.
-
#ward_r ⇒ Object
readonly
Returns the value of attribute ward_r.
Class Method Summary collapse
-
.from_json(hash) ⇒ SingleCity
JSON(パース済み Hash・文字列キー)から VO を生成する Ruby 独自ヘルパ。.
- .new ⇒ instance
Instance Method Summary collapse
-
#city_name ⇒ String
JS: cityName(city) =>
${city.county || ''}${city.city}${city.ward || ''}nil の補間は Ruby では空文字になるため|| ''相当。.
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def city @city end |
#city_k ⇒ Object (readonly)
Returns the value of attribute city_k
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def city_k @city_k end |
#city_r ⇒ Object (readonly)
Returns the value of attribute city_r
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def city_r @city_r end |
#code ⇒ Object (readonly)
Returns the value of attribute code
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def code @code end |
#county ⇒ Object (readonly)
Returns the value of attribute county
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def county @county end |
#county_k ⇒ Object (readonly)
Returns the value of attribute county_k
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def county_k @county_k end |
#county_r ⇒ Object (readonly)
Returns the value of attribute county_r
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def county_r @county_r end |
#point ⇒ Object (readonly)
Returns the value of attribute point
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def point @point end |
#ward ⇒ Object (readonly)
Returns the value of attribute ward
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def ward @ward end |
#ward_k ⇒ Object (readonly)
Returns the value of attribute ward_k
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def ward_k @ward_k end |
#ward_r ⇒ Object (readonly)
Returns the value of attribute ward_r
11 12 13 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 11 def ward_r @ward_r end |
Class Method Details
.from_json(hash) ⇒ SingleCity
JSON(パース済み Hash・文字列キー)から VO を生成する Ruby 独自ヘルパ。
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 16 def self.from_json(hash) new( code: hash['code'], county: hash['county'], county_k: hash['county_k'], county_r: hash['county_r'], city: hash['city'], city_k: hash['city_k'], city_r: hash['city_r'], ward: hash['ward'], ward_k: hash['ward_k'], ward_r: hash['ward_r'], point: hash['point'] ) end |
.new ⇒ instance
19 |
# File 'sig/data.rbs', line 19
def self.new: (code: Integer, county: String?, county_k: String?, county_r: String?, city: String, city_k: String, city_r: String, ward: String?, ward_k: String?, ward_r: String?, point: [Float, Float]) -> instance
|
Instance Method Details
#city_name ⇒ String
JS: cityName(city) => ${city.county || ''}${city.city}${city.ward || ''}
nil の補間は Ruby では空文字になるため || '' 相当。
34 35 36 |
# File 'lib/japanese_address_parser/data/single_city.rb', line 34 def city_name "#{county}#{city}#{ward}" end |