Class: TokyoMetro::Factory::Seed::Api::StationTrainTime::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/tokyo_metro/factory/seed/api/station_train_time/checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(*symbol_of_railway_lines) ⇒ Checker

Returns a new instance of Checker.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tokyo_metro/factory/seed/api/station_train_time/checker.rb', line 3

def initialize( *symbol_of_railway_lines )
  raise "Error" unless symbol_of_railway_lines.all? { |s| s.instance_of?( Symbol ) }

  @symbol_of_railway_lines = symbol_of_railway_lines.flatten.sort

  railway_lines_same_as = @symbol_of_railway_lines.map { | symbol |
    ::TokyoMetro::Modules::Common::Dictionary::RailwayLine::StringList.railway_line_string_list_in_system( symbol )
  }.flatten

  @railway_line_ids = ::RailwayLine.where( same_as: railway_lines_same_as ).pluck( :id )

  #--------

  @station_timetable_ids = ::StationTimetableFundamentalInfo.where( railway_line_id: @railway_line_ids ).pluck( :station_timetable_id ).sort
  @train_timetable_ids = ::TrainTimetable.where( railway_line_id: @railway_line_ids ).pluck( :id ).sort

  #--------

  @station_train_times_from_station_timetables = ::StationTrainTime.where( station_timetable_id: @station_timetable_ids ).pluck( :id ).sort
  @station_train_times_from_train_timetables = ::StationTrainTime.where( train_timetable_id: @train_timetable_ids ).pluck( :id ).sort

  @number_of_station_train_times_in_api = ::TokyoMetro::Api.train_timetables.send( :select_railway_line , *( @symbol_of_railway_lines ) ).map { | train_timetable |
    train_timetable.valid_list.length
  }.inject( :+ )
end

Instance Method Details

#check_numberObject



29
30
31
32
33
# File 'lib/tokyo_metro/factory/seed/api/station_train_time/checker.rb', line 29

def check_number
  display_normal_info
  display_match_or_not
  return nil
end

#destroy!Object



35
36
37
38
39
40
41
42
# File 'lib/tokyo_metro/factory/seed/api/station_train_time/checker.rb', line 35

def destroy!
  display_before_destroy
  a = ::STDIN.gets.chomp
  @station_train_times_from_train_timetables.each do | station_train_time_id |
    ::StationTrainTime.find( station_train_time_id ).destroy
  end
  return nil
end

#display_railway_line_info_in_dbObject



44
45
46
47
48
# File 'lib/tokyo_metro/factory/seed/api/station_train_time/checker.rb', line 44

def display_railway_line_info_in_db
  display_station_timetable_info_in_db
  display_train_timetable_info_in_db
  return nil
end