Class: GeoMasterJp::Line
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- GeoMasterJp::Line
- Defined in:
- app/models/geo_master_jp/line.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.inherited(child) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/geo_master_jp/line.rb', line 25 def self.inherited(child) child.belongs_to :railway_company, class_name: GeoMasterJp.config.alternative_class_name(:railway_company), foreign_key: :geo_master_jp_railway_company_code, primary_key: :code child.has_many :stations, class_name: GeoMasterJp.config.alternative_class_name(:station), foreign_key: :geo_master_jp_line_code, primary_key: :code if GeoMasterJp.config.use_models.include?(:area) child.has_many :prefectures_lines, class_name: GeoMasterJp.config.alternative_class_name(:prefectures_line), foreign_key: :geo_master_jp_line_code, primary_key: :code child.has_many :prefectures, through: :prefectures_lines, class_name: GeoMasterJp.config.alternative_class_name(:prefecture) end super end |
.select_options(transactions = nil) ⇒ Object
41 42 43 |
# File 'app/models/geo_master_jp/line.rb', line 41 def self.(transactions=nil) (transactions || all).map{|line| [line.name, line.code] } end |
Instance Method Details
#head_kana ⇒ Object
19 20 21 22 23 |
# File 'app/models/geo_master_jp/line.rb', line 19 def head_kana return '' if self.name_kana.blank? head_kanas = ['ア', 'カ', 'サ', 'タ', 'ナ', 'ハ', 'マ', 'ヤ', 'ラ', 'ワ'] head_kanas[head_kanas.index{|i| i > self.name_kana[0] }.to_i - 1] end |
#station_select_options ⇒ Object
37 38 39 |
# File 'app/models/geo_master_jp/line.rb', line 37 def self.stations.map{|station| [station.name, station.code] } end |