Sha256: 102252c2a0e298b7d0d7ce246159b5d910a392c6a0ad5509da3c5b896949490c

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# 各社・各種別に共通するメタクラス
class TokyoMetro::Api::StationTimetable::Info::TrainTime::Info::Note::YurakuchoFukusohin::TrainType::Fundamental

  # Constructor
  def initialize( border , railway_line , train_type , train_type_in_db )
    @border = border
    @railway_line = railway_line
    @train_type = train_type
    @train_type_in_db = train_type_in_db
  end

  attr_reader :border
  attr_reader :railway_line
  attr_reader :train_type
  attr_reader :train_type_in_db

  # インスタンスの情報を文字列にして返すメソッド
  # @return [String]
  def to_s
    "#{@border.to_s}から先、#{@railway_line.to_s}線内は#{@train_type.to_s}として運行します。"
  end

  def seed_and_get_id
    station_info_in_db = ::Station::Info.find_by( name_ja: @border , railway_line_id: railway_line_on_the_border_station_info_in_db.id )
    train_type_instance = ::TrainType.find_by_same_as( @train_type_in_db )

    h = {
      railway_line_id: railway_line_in_db.id ,
      from_station_info_id: station_info_in_db.id ,
      train_type_id: train_type_instance.id ,
      note: self.to_s
    }
    ::TrainTimetableTrainTypeInOtherOperator.find_or_create_by(h).id
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/api/station_timetable/info/train_time/info/note/yurakucho_fukutoshin/train_type/fundamental.rb