Module: TokyoMetro
- Defined in:
- lib/tokyo_metro.rb,
lib/tokyo_metro/version.rb
Overview
Defined Under Namespace
Modules: Api, ApiProcessor, App, ClassNameLibrary, Dictionary, Document, Factory, Initializer, Modules, Rake, Refinement, Search, Static, TempLib, Test
Classes: Required
- API_ENDPOINT =
東京メトロオープンデータ API のエンドポイント
"https://api.tokyometroapp.jp/api/v2"
- DATAPOINTS_URL =
"#{API_ENDPOINT}/datapoints"
- PLACES_URL =
"#{API_ENDPOINT}/places"
- STATION_DICTIONARY =
::YAML.load_file( "#{ DICTIONARY_DIR }/station/tokyo_metro.yaml" )
- DATE_CHANGING_HOUR =
3
- DEFAULT_TIME_ZONE =
::Kernel.Rational(9,24)
Constant Summary
collapse
- LIB_DIR =
::File.expand_path( ::File.dirname( __FILE__ ) )
- TOP_DIR =
Note:
“#{ ::Rails.root }” とはしない
Gem のトップディレクトリ
::File.expand_path( "#{ LIB_DIR }/.." )
- DICTIONARY_DIR =
::File.expand_path( "#{ LIB_DIR }/tokyo_metro/dictionary" )
- VERSION =
::File.open( "#{ ::File.dirname( __FILE__ ) }/../../.current_version" , "r:utf-8" ).read.chomp
Class Method Details
.current_diagram ⇒ Object
185
186
187
|
# File 'lib/tokyo_metro.rb', line 185
def self.current_diagram
diagram_as_of( current_operation_day )
end
|
.current_operation_day ⇒ Object
.diagram_as_of(time) ⇒ Object
.google_maps_javasciprt_uri ⇒ Object
158
159
160
|
# 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) ⇒ Object
146
147
148
149
150
151
152
153
|
# 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) ⇒ Object
192
193
194
195
196
197
198
199
200
201
|
# 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) ⇒ Object
.reload_all_files! ⇒ Object
133
134
135
136
137
|
# 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") ⇒ Object
139
140
141
142
143
144
|
# 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 ⇒ Object
123
124
125
|
# 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 ⇒ Object
127
128
129
|
# 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) ⇒ Object
119
120
121
|
# 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) ⇒ Object
114
115
116
117
|
# 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 ⇒ Object
.set_rails_consts(rails_dir = ::Rails.root.to_s) ⇒ Object
.station_dictionary_including_main_info(stations_of_railway_lines = nil) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# 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) ⇒ DateTime
94
95
96
97
|
# 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
|