Class: TokyoMetro::Api::TrainLocation
- Inherits:
-
MetaClass::RealTime
- Object
- MetaClass::Fundamental
- MetaClass::DataSearch
- MetaClass::RealTime
- TokyoMetro::Api::TrainLocation
- Includes:
- ClassNameLibrary::Api::TrainLocation, Modules::Api::ToFactory::Generate::Group::TrainLocation
- Defined in:
- lib/tokyo_metro/api/train_location.rb
Overview
Note:
列車の在線位置を表す。列車ロケーション情報は、駅にいる状態(odpt:fromStation のみ値が存在)、「駅間を走行中」という状態(odpt:fromStation, odpt:toStation の両方に値が存在)を用いた相対位置情報表記に対応する。
Note:
列車ロケーション情報は、始発から終電まで、列車が運行している時間帯に取得可能である。
Note:
始発駅や終着駅には、東京メトロ以外の駅名が出現する場合があるが、他社の駅時刻表や駅情報等は提供しない。
列車ロケーション情報 odpt:Train を扱うクラス
Defined Under Namespace
クラスメソッド - データの取得・保存 collapse
-
.get(http_client, railway_line, id_urn: nil, same_as: nil, train_number: nil, train_type: nil, train_owner: nil, railway_direction: nil, delay: nil, starting_station: nil, terminal_station: nil, from_station: nil, to_station: nil, parse_json: false, generate_instance: false, to_inspect: false) ⇒ ::Array
列車ロケーション情報 odpt:Train を取得するメソッド.
-
.save(http_client, filename, railway_line, file_type: :yaml, id_urn: nil, same_as: nil, train_number: nil, train_type: nil, train_owner: nil, railway_direction: nil, delay: nil, starting_station: nil, terminal_station: nil, from_station: nil, to_station: nil, to_inspect: false) ⇒ nil
列車ロケーション情報 odpt:Train を取得し保存するメソッド.
-
.save_datas_of_all_railway_lines(http_client, file_type: :yaml, generate_instance: false, to_inspect: true) ⇒ Object
各路線の列車ロケーション情報を取得し保存するメソッド.
-
.save_datas_of_each_group(http_client, railway_line, file_type: :yaml, generate_instance: false, to_inspect: true) ⇒ nil
個別の列車ロケーション情報を取得し保存するメソッド.
テスト collapse
Methods inherited from MetaClass::Fundamental
factory_for_generating_from_saved_file
Class Method Details
.get(http_client, railway_line, id_urn: nil, same_as: nil, train_number: nil, train_type: nil, train_owner: nil, railway_direction: nil, delay: nil, starting_station: nil, terminal_station: nil, from_station: nil, to_station: nil, parse_json: false, generate_instance: false, to_inspect: false) ⇒ ::Array
列車ロケーション情報 odpt:Train を取得するメソッド
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tokyo_metro/api/train_location.rb', line 31 def self.get( http_client , railway_line , id_urn: nil , same_as: nil , train_number: nil , train_type: nil , train_owner: nil , railway_direction: nil , delay: nil , starting_station: nil , terminal_station: nil , from_station: nil , to_station: nil , parse_json: false , generate_instance: false , to_inspect: false ) factory_for_getting.process( http_client , railway_line , id_urn , same_as , train_number , train_type , train_owner , railway_direction , delay , starting_station , terminal_station , from_station , to_station , parse_json , generate_instance , to_inspect ) end |
.get_test(http_client, railway_line_name) ⇒ nil
データ取得のテスト
117 118 119 120 121 122 |
# File 'lib/tokyo_metro/api/train_location.rb', line 117 def self.get_test( http_client , railway_line_name ) puts "● Train location" railway_line_name = "odpt.Railway:#{railway_line_name}" train_location = get( http_client , railway_line_name , to_inspect: true , parse_json: true , generate_instance: true ) puts train_location.to_strf end |
.save(http_client, filename, railway_line, file_type: :yaml, id_urn: nil, same_as: nil, train_number: nil, train_type: nil, train_owner: nil, railway_direction: nil, delay: nil, starting_station: nil, terminal_station: nil, from_station: nil, to_station: nil, to_inspect: false) ⇒ nil
列車ロケーション情報 odpt:Train を取得し保存するメソッド
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tokyo_metro/api/train_location.rb', line 60 def self.save( http_client , filename , railway_line , file_type: :yaml , id_urn: nil , same_as: nil , train_number: nil , train_type: nil , train_owner: nil , railway_direction: nil , delay: nil , starting_station: nil , terminal_station: nil , from_station: nil , to_station: nil , to_inspect: false ) data = get( http_client , railway_line , id_urn: id_urn , same_as: same_as , train_number: train_number , train_type: train_type , train_owner: train_owner , railway_direction: railway_direction , delay: delay , starting_station: starting_station , terminal_station: terminal_station , from_station: from_station , to_station: to_station , parse_json: true , generate_instance: generate_instance , to_inspect: to_inspect ) save_data( data , filename , file_type: file_type ) end |
.save_datas_of_all_railway_lines(http_client, file_type: :yaml, generate_instance: false, to_inspect: true) ⇒ Object
各路線の列車ロケーション情報を取得し保存するメソッド
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/tokyo_metro/api/train_location.rb', line 79 def self.save_datas_of_all_railway_lines( http_client , file_type: :yaml , generate_instance: false , to_inspect: true ) # 路線のリスト # @return [::Array] railway_line_list = [ "odpt.Railway:TokyoMetro.Ginza" , "odpt.Railway:TokyoMetro.Marunouchi" , # "odpt.Railway:TokyoMetro.MarunouchiBranch" , "odpt.Railway:TokyoMetro.Hibiya" , "odpt.Railway:TokyoMetro.Tozai" , "odpt.Railway:TokyoMetro.Chiyoda" , "odpt.Railway:TokyoMetro.Yurakucho" , "odpt.Railway:TokyoMetro.Hanzomon" , "odpt.Railway:TokyoMetro.Namboku" , "odpt.Railway:TokyoMetro.Fukutoshin" ] railway_line_list.each do | railway_line | save_datas_of_each_group( http_client , railway_line , file_type: file_type , generate_instance: generate_instance , to_inspect: to_inspect ) sleep(1) end end |
.save_datas_of_each_group(http_client, railway_line, file_type: :yaml, generate_instance: false, to_inspect: true) ⇒ nil
個別の列車ロケーション情報を取得し保存するメソッド
107 108 109 |
# File 'lib/tokyo_metro/api/train_location.rb', line 107 def self.save_datas_of_each_group( http_client , railway_line , file_type: :yaml , generate_instance: false , to_inspect: true ) factory_for_saving_datas_of_each_group.process( http_client , railway_line , db_dirname , file_type , generate_instance , to_inspect ) end |