module TokyoMetro
東京メトロ オープンデータを扱うモジュール
Constants
- API_ENDPOINT
東京メトロオープンデータ API のエンドポイント
- DATAPOINTS_URL
データ取得・検索 API
- DATE_CHANGING_HOUR
ダイヤ上の日付変更時刻
- DEFAULT_TIME_ZONE
- DICTIONARY_DIR
辞書ファイルのディレクトリ
- LIB_DIR
- PLACES_URL
地物情報取得・検索 API
- STATION_DICTIONARY
@!group 駅名辞書
- TOP_DIR
Gem のトップディレクトリ @note “#{ ::Rails.root }” とはしない
- VERSION
Public Class Methods
current_diagram()
click to toggle source
# File lib/tokyo_metro.rb, line 185 def self.current_diagram diagram_as_of( current_operation_day ) end
current_operation_day()
click to toggle source
@!group 運行日に関するメソッド
# File lib/tokyo_metro.rb, line 170 def self.current_operation_day ::TokyoMetro::Static::OperationDay.of_current end
diagram_as_of( time )
click to toggle source
@!group 運行ダイヤに関するメソッド
# File lib/tokyo_metro.rb, line 180 def self.diagram_as_of( time ) t = operation_day_as_of( time ) ::TokyoMetro::Modules::Db::Select::OperationDay.process(t) end
google_maps_javasciprt_uri()
click to toggle source
@see developers.google.com/maps/documentation/javascript/tutorial?hl=ja
# File lib/tokyo_metro.rb, line 158 def self.google_maps_javasciprt_uri "https://maps.googleapis.com/maps/api/js?key=#{ GOOGLE_MAPS_API_KEY }&sensor=true" end
initialize_in_local_environment( rails_dir )
click to toggle source
# File lib/tokyo_metro.rb, line 146 def self.initialize_in_local_environment( rails_dir ) set_rails_consts( rails_dir ) set_modules set_fundamental_constants set_access_token set_google_maps_api_key end
method_missing( method_name , *args )
click to toggle source
Calls superclass method
# File lib/tokyo_metro.rb, line 192 def method_missing( method_name , *args ) if /const/ === method_name.to_s valid_method_name = method_name.to_s.gsub( "const" , "constant" ) if methods.map( &:to_s ).include?( valid_method_name ) return send( valid_method_name , *args ) end end super( method_name , *args ) end
operation_day_as_of( time )
click to toggle source
# File lib/tokyo_metro.rb, line 174 def self.operation_day_as_of( time ) ::TokyoMetro::Static::OperationDay.as_of( time ) end
reload_all_files!()
click to toggle source
@!group 関連ファイルのロード
# File lib/tokyo_metro.rb, line 133 def self.reload_all_files! open( "#{ TOP_DIR }/required_files.txt" , "r:utf-8" ).read.split( /\n/ ).each do |f| load "#{ ::Rails.root }/#{ f }" end end
require_files( settings: nil , file_type: "txt" )
click to toggle source
# File lib/tokyo_metro.rb, line 139 def self.require_files( settings: nil , file_type: "txt" ) settings ||= :make_list_of_required_files required_files( settings , file_type ).each do | filename | require filename end end
set_all_api_constants()
click to toggle source
# File lib/tokyo_metro.rb, line 123 def self.set_all_api_constants set_api_constants( config_of_api_constants_when_load_all ) end
set_all_api_constants_without_fare()
click to toggle source
# File lib/tokyo_metro.rb, line 127 def self.set_all_api_constants_without_fare set_api_constants( config_of_api_constants_when_load_without_fare ) end
set_api_constants( config_of_api_constants = nil )
click to toggle source
# File lib/tokyo_metro.rb, line 119 def self.set_api_constants( config_of_api_constants = nil ) ::TokyoMetro::Api::set_constants( config_of_api_constants ) end
set_constants( config_of_api_constants = nil )
click to toggle source
# File lib/tokyo_metro.rb, line 114 def self.set_constants( config_of_api_constants = nil ) set_fundamental_constants set_api_constants( config_of_api_constants ) end
set_fundamental_constants()
click to toggle source
定数の定義
# File lib/tokyo_metro.rb, line 109 def self.set_fundamental_constants ::TokyoMetro::Static::set_constants ::TokyoMetro::Api.set_constants_for_timetable end
set_modules()
click to toggle source
@!group モジュールの組み込み
# File lib/tokyo_metro.rb, line 101 def self.set_modules ::TokyoMetro::Initializer::Modules.set end
set_rails_consts( rails_dir = ::Rails.root.to_s )
click to toggle source
@!group Rails 関連
# File lib/tokyo_metro.rb, line 164 def self.set_rails_consts( rails_dir = ::Rails.root.to_s ) ::TokyoMetro::Initializer::Rails.consts_in_gem.set( as_for: rails_dir ) end
station_dictionary_including_main_info( stations_of_railway_lines = nil )
click to toggle source
# File lib/tokyo_metro.rb, line 62 def self.station_dictionary_including_main_info( stations_of_railway_lines = nil ) if stations_of_railway_lines.nil? stations_of_railway_lines = ::Station::Info.where( operator_id: ::Operator.id_of_tokyo_metro ) end h = ::Hash.new station_dictionary.each do | name_in_system , name_ja | stations_in_db = stations_of_railway_lines.where( name_in_system: name_in_system ) name_h = { :name_ja => stations_in_db.first.name_ja , :name_hira => stations_in_db.first.name_hira , :name_en => stations_in_db.first.name_en , :name_in_system => name_in_system , :station_codes => stations_in_db.pluck( :station_code ) } h[ name_in_system ] = name_h end return h end
time_now( time_zone: nil )
click to toggle source
現在時刻 @note タイムゾーンは日本時間 (GMT+9) @return [DateTime]
# File lib/tokyo_metro.rb, line 94 def self.time_now( time_zone: nil ) rational_for_time_zone ||= DEFAULT_TIME_ZONE ::DateTime.now.new_offset( rational_for_time_zone ) end
Private Class Methods
api_constant_keys()
click to toggle source
# File lib/tokyo_metro.rb, line 285 def api_constant_keys [ :station_facility , :passenger_survey , :station , :railway_line , :point , :fare , :station_timetable , :train_timetable ] end
config_of_api_constants_when_load_all()
click to toggle source
# File lib/tokyo_metro.rb, line 269 def config_of_api_constants_when_load_all h = ::Hash.new api_constant_keys.each do | key | h[ key ] = true end h end
config_of_api_constants_when_load_without_fare()
click to toggle source
# File lib/tokyo_metro.rb, line 277 def config_of_api_constants_when_load_without_fare h = ::Hash.new ( api_constant_keys - [ :fare ] ).each do | key | h[ key ] = true end h end
required_files( settings , file_type )
click to toggle source
# File lib/tokyo_metro.rb, line 289 def required_files( settings , file_type ) raise "Error: settings '#{ settings }' is not valid." unless [ "from_txt" , "make_list_of_required_files" , "update" , "development" , "production" , "test" , "staging"].include?( settings.to_s ) raise "Error" unless [ "txt" , "yaml" , "json" , "cson" ].include?( file_type.to_s ) case settings.to_s when "from_txt" , "production" , "test" ::RequiredFiles::Get.send( "from_#{ file_type }" , ::TokyoMetro::TOP_DIR , "required_files" ) else require_relative "tokyo_metro/required.rb" require_relative "tokyo_metro/required/all.rb" ::Dir.glob( "#{ ::TokyoMetro::LIB_DIR }/tokyo_metro/required/all/**/**.rb" ).sort.each do | filename | require ::File.expand_path( filename ) end ::TokyoMetro::Required::All.files( file_type ) end end