Class: Basho::DB::City
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Basho::DB::City
- Defined in:
- lib/basho/db/city.rb
Overview
市区町村のActiveRecordモデル(+basho_cities+ テーブル)。 メモリ版 City と同じAPI(+full_name+, +capital?+)を提供する。
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#current ⇒ Basho::DB::City
合併チェーンをたどって現行の自治体を返す(ループ検出・深度制限付き)。.
- #deprecated? ⇒ Boolean
-
#full_name ⇒ String
郡名付きの正式名を返す。.
Instance Method Details
#active? ⇒ Boolean
26 |
# File 'lib/basho/db/city.rb', line 26 def active? = deprecated_at.nil? |
#current ⇒ Basho::DB::City
合併チェーンをたどって現行の自治体を返す(ループ検出・深度制限付き)。
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/basho/db/city.rb', line 31 def current city = self seen = Set.new while city.successor_code.present? && seen.add?(city.successor_code) break if seen.size > MAX_SUCCESSOR_DEPTH next_city = city.successor break unless next_city city = next_city end city end |
#deprecated? ⇒ Boolean
25 |
# File 'lib/basho/db/city.rb', line 25 def deprecated? = deprecated_at.present? |
#full_name ⇒ String
郡名付きの正式名を返す。
48 49 50 |
# File 'lib/basho/db/city.rb', line 48 def full_name district ? "#{district}#{name}" : name end |