Module: TokyoMetro::Api

Includes:
Modules::Common::ConvertConstantToClassMethod
Defined in:
lib/tokyo_metro/api.rb

Overview

東京メトロ オープンデータの API から提供される情報を扱うモジュール

Defined Under Namespace

Modules: MetaClass Classes: Fare, MlitRailwayLine, MlitStation, PassengerSurvey, Point, RailwayLine, Station, StationFacility, StationTimetable, StationTrainTime, TrainLocation, TrainOperation, TrainTimetable

時刻表の列車の補足情報に関する定数の定義 collapse

Class Method Summary collapse

Class Method Details

.barrier_free_facilitiesObject



30
31
32
# File 'lib/tokyo_metro/api.rb', line 30

def self.barrier_free_facilities
  STATION_FACILITY.send( __method__ )
end

.factory_for_gettingObject



153
154
155
# File 'lib/tokyo_metro/api.rb', line 153

def self.factory_for_getting
  ::TokyoMetro::Factory::Get::Api::DataSearch
end

.factory_for_getting_geoObject



157
158
159
# File 'lib/tokyo_metro/api.rb', line 157

def self.factory_for_getting_geo
  ::TokyoMetro::Factory::Get::Api::Geo
end

.get(http_client, id_urn, parse_json: false, generate_instance: false, to_inspect: false) ⇒ Object



145
146
147
# File 'lib/tokyo_metro/api.rb', line 145

def self.get( http_client , id_urn , parse_json: false , generate_instance: false , to_inspect: false )
  factory_for_getting.process( http_client , id_urn , parse_json , generate_instance , to_inspect )
end

.get_geo(http_client, id_urn, parse_json: false, generate_instance: false, to_inspect: false) ⇒ Object



149
150
151
# File 'lib/tokyo_metro/api.rb', line 149

def self.get_geo( http_client , id_urn , parse_json: false , generate_instance: false , to_inspect: false )
  factory_for_getting_geo.process( http_client , id_urn , parse_json , generate_instance , to_inspect )
end

.list_of_constantsObject



10
11
12
# File 'lib/tokyo_metro/api.rb', line 10

def self.list_of_constants
  [ :station_facility , :passenger_survey , :station , :railway_line , :point , :fare , :station_timetable , :train_timetable ]
end

.method_missing(method_name, *args) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/tokyo_metro/api.rb', line 36

def method_missing( method_name , *args )
  if costants_converted_by_method_missing.include?( method_name.singularize.upcase )
    return const_get( method_name.singularize.upcase )
  else
    super( method_name , *args )
  end
end

.set_constants(*configs_of_api_constants) ⇒ nil

東京メトロ オープンデータに関する定数を定義するメソッド (2) - API から取得し保存したデータからインスタンスを作成し、定数とする

Returns:

  • (nil)


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tokyo_metro/api.rb', line 16

def self.set_constants( *configs_of_api_constants )
  config_of_api_constants = set_config_of_api_constants( *configs_of_api_constants )

  if config_of_api_constants.present?
    list_of_constants.each do | symbol |
      if config_of_api_constants[ symbol ]
        set_constant( symbol )
      end
    end
  end

  return nil
end

.set_constants_for_timetablenil

東京メトロ オープンデータに関する定数を定義するメソッド (1) - 時刻表の列車の補足情報に関する定数

Returns:

  • (nil)


129
130
131
132
133
134
135
# File 'lib/tokyo_metro/api.rb', line 129

def self.set_constants_for_timetable
  #---- 時刻表 到着ホーム
  ::TokyoMetro::Api::StationTimetable::Info::TrainTime::Info::Note::ArriveAt::set_constants

  #---- 時刻表 出発ホーム
  ::TokyoMetro::Api::StationTimetable::Info::TrainTime::Info::Note::PlatformNumber::set_constant
end

.station_train_timeObject



6
7
8
# File 'lib/tokyo_metro/api.rb', line 6

def self.station_train_time
  ::TokyoMetro::Api::StationTrainTime
end

.timetable_notes_of_arrival_at_asakusaObject



137
138
139
# File 'lib/tokyo_metro/api.rb', line 137

def self.timetable_notes_of_arrival_at_asakusa
  ::TokyoMetro::Api::StationTimetable::Info::TrainTime::Info::Note::ArriveAt::ASAKUSA
end

.timetable_notes_of_departureObject



141
142
143
# File 'lib/tokyo_metro/api.rb', line 141

def self.timetable_notes_of_departure
  ::TokyoMetro::Api::StationTimetable::Info::TrainTime::Info::Note::PlatformNumber::LIST
end