class TokyoMetro::Api::StationTimetable::Info::TrainTime::Info::Note::ArriveAt

到着ホームの情報を扱うクラス

Attributes

number[R]

@return [Integer] 到着ホーム

sta[R]

@return [String] 到着駅

station[R]

@return [String] 到着駅

Public Class Methods

new( sta , number ) click to toggle source

Constructor @param sta [String] 到着駅 @param number [Integer] 到着ホーム

# File lib/tokyo_metro/api/station_timetable/info/train_time/info/note/arrive_at.rb, line 7
def initialize( sta , number )
  @station = sta
  @number = number
end
set_constants() click to toggle source

複数の定数を定義するメソッド @return [nil]

# File lib/tokyo_metro/api/station_timetable/info/train_time/info/note/arrive_at.rb, line 50
def self.set_constants
  set_constant( :ASAKUSA , "浅草" , 1 , 2 )
  return nil
end
set_from_string( str , i ) click to toggle source

駅名と到着ホームからインスタンスを取得するメソッド @param str [String] 駅名 @param i [Integer] 到着ホーム @return [ArriveAt]

# File lib/tokyo_metro/api/station_timetable/info/train_time/info/note/arrive_at.rb, line 59
def self.set_from_string( str , i )
  case str
  when "浅草"
    ASAKUSA[i]
  else
    raise "Error"
  end
end

Private Class Methods

set_constant( const_name , sta , min_i , max_i ) click to toggle source
# File lib/tokyo_metro/api/station_timetable/info/train_time/info/note/arrive_at.rb, line 72
def set_constant( const_name , sta , min_i , max_i )
  h = Hash.new
  ( min_i..max_i ).each do |i|
    h[i] = self.new( sta , i )
  end
  const_set( const_name , h )
end

Public Instance Methods

<=>( other_instance ) click to toggle source

他のインスタンスとの比較に使用するメソッド @param other_instance [ArriveAt] 比較対象のインスタンス @return [Integer]

# File lib/tokyo_metro/api/station_timetable/info/train_time/info/note/arrive_at.rb, line 27
def <=>( other_instance )
  if @station == other_instance.station
    if @number == other_instance.number
      0
    else
      @number <=> other_instance.number
    end
  else
    @station <=> other_instance.station
  end
end
seed_and_get_id( railway_line_ids ) click to toggle source
# File lib/tokyo_metro/api/station_timetable/info/train_time/info/note/arrive_at.rb, line 39
def seed_and_get_id( railway_line_ids )
  station_info_in_db = ::Station::Info.find_by( name_ja: @station , railway_line_id: railway_line_ids )
  h = {
    station_info_id: station_info_in_db.id ,
    platform_number: @number
  }
  ::TrainTimetableArrivalInfo.find_or_create_by(h).id
end
to_s() click to toggle source

自身の情報を文字列に変換して返すメソッド @return [String]

# File lib/tokyo_metro/api/station_timetable/info/train_time/info/note/arrive_at.rb, line 20
def to_s
  "#{@station}では#{@number}番線に到着"
end