Class: TokyoMetro::Api::TrainLocation::Info
- Inherits:
-
MetaClass::RealTime::Info
- Object
- MetaClass::Fundamental::Info
- MetaClass::RealTime::Info
- TokyoMetro::Api::TrainLocation::Info
- Includes:
- ClassNameLibrary::Api::TrainLocation, Modules::Api::Info::Decision::CurrentStation, Modules::Api::Info::Decision::OperatedSection, Modules::Api::Info::Decision::RailwayLine, Modules::Api::Info::Decision::StartingStation, Modules::Api::Info::Decision::TerminalStation, Modules::Api::Info::Decision::TrainDirection, Modules::Api::Info::Decision::TrainType, Modules::Api::Info::ToStringGeneral, Modules::Common::Info::Decision::CompareBase, Modules::Common::Info::Decision::RomanceCar, Modules::Common::Info::Decision::ToeiMitaLine
- Defined in:
- lib/tokyo_metro/api/train_location/info.rb
Overview
個別の列車のロケーション情報を扱うクラス
Defined Under Namespace
Classes: Delay
列車ロケーション情報のメタデータ (For developers) collapse
-
#dc_date ⇒ DateTime
readonly
データ生成時刻 - xsd:dateTime(ISO8601 日付時刻形式をもとに生成した DateTime のインスタンス).
-
#frequency ⇒ Integer
readonly
更新頻度(秒) - xsd:integer.
-
#same_as ⇒ String
readonly
固有識別子 - URL.
-
#valid ⇒ DateTime
readonly
データ保証期限 - xsd:dateTime(ISO8601 日付時刻形式をもとに生成した DateTime のインスタンス).
列車情報 (For users) collapse
-
#railway_direction ⇒ String
readonly
方面 - odpt:RailDirection.
-
#railway_line ⇒ String
readonly
鉄道路線ID - odpt:Railway.
-
#starting_station ⇒ String
readonly
列車の始発駅 - odpt:Station.
-
#terminal_station ⇒ String
readonly
列車の終着駅 - odpt:Station.
-
#train_number ⇒ String
readonly
列車番号 - xsd:string.
-
#train_owner ⇒ String
readonly
車両の所属会社 - odpt:TrainOwner.
-
#train_type ⇒ String
readonly
列車種別 - odpt:TrainType.
遅延 (For users) collapse
-
#delay ⇒ Integer
readonly
遅延時間(秒) - xsd:integer.
列車ロケーション情報 (For users) collapse
-
#from_station ⇒ String
readonly
列車が出発した駅 - odpt:Station.
-
#to_station ⇒ String?
readonly
列車が向かっている駅 - odpt:Station.
-
#train_name ⇒ Object
readonly
Returns the value of attribute train_name.
Attributes inherited from MetaClass::Fundamental::Info
遅延情報に関するメソッド (For users) collapse
- #actual_delay ⇒ Object
-
#delay_now?(delay_minimum_second) ⇒ Boolean
遅延しているか否かを判定するメソッド.
- #on_schedule? ⇒ Boolean
列車の現在位置に関するメソッド (For users) collapse
-
#between_station? ⇒ Boolean
列車が駅間にいるか否かの真偽値(駅間にいる場合は true ).
- #delay_instance ⇒ Object
-
#now_at_station? ⇒ Boolean
列車が駅に停車中か否かの真偽値(駅に停車中の場合は true ).
Instance Method Summary collapse
- #before_decorate ⇒ Object
- #decorate(request, railway_line) ⇒ Object
-
#initialize(id_urn, same_as, train_number, train_type, dc_date, valid, frequency, railway_line, train_owner, railway_direction, delay, starting_station, terminal_station, from_station, to_station) ⇒ Info
constructor
Constructor.
-
#to_h ⇒ Hash
インスタンスの情報をハッシュにして返すメソッド.
Methods included from Modules::Api::Info::Decision::OperatedSection
#marunouchi_main_and_branch_line?, #operated_only_on_chiyoda_branch_line?, #operated_only_on_chiyoda_branch_line_including_invalid?, #operated_only_on_marunouchi_branch_line?, #operated_only_on_marunouchi_branch_line_including_invalid?
Methods included from Modules::Api::Info::Decision::TerminalStation
Methods included from Modules::Common::Info::Decision::TerminalStation
#bound_for?, #terminating_on_marunouchi_branch_line_including_invalid?, #terminating_on_tokyu_toyoko_or_at_motomachi_chukagai?, #terminating_on_tokyu_toyoko_or_minatomirai_line?
Methods included from Modules::Common::Info::Decision::StartingStation
#starting_on_marunouchi_branch_line_including_invalid?, #starting_on_tokyu_toyoko_or_at_motomachi_chukagai?, #starting_on_tokyu_toyoko_or_minatomirai_line?
Methods included from Modules::Api::Info::Decision::TrainDirection
Methods included from Modules::Common::Info::Decision::TrainType
#express?, #limited_express_or_romance_car?, #local?, #romance_car_specific_train?
Methods included from Modules::Common::Info::Decision::RailwayLine
#on_marunouchi_line_including_branch?, #on_namboku_or_toei_mita_line?, #on_toei_mita_line?, #on_yurakucho_or_fukutoshin_line?
Methods included from Modules::Common::Info::Decision::RomanceCar
#romance_car_on_chiyoda_line?, #romance_car_specific_train_on_chiyoda_line?
Methods included from Modules::Common::Info::Decision::ToeiMitaLine
#toei_mita_line_train_including_on_namboku_line?
Methods included from Modules::Api::Info::ToStringGeneral
Methods included from Modules::Api::Info::Validity
Methods included from Modules::Api::Info::ToJson
Constructor Details
#initialize(id_urn, same_as, train_number, train_type, dc_date, valid, frequency, railway_line, train_owner, railway_direction, delay, starting_station, terminal_station, from_station, to_station) ⇒ Info
Constructor
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 22 def initialize( id_urn , same_as , train_number , train_type , dc_date , valid , frequency , railway_line , train_owner , railway_direction , delay , starting_station , terminal_station , from_station , to_station ) @id_urn = id_urn @same_as = same_as @dc_date , @valid , @frequency = dc_date , valid , frequency @train_number , @train_type = train_number , train_type @railway_line , @train_owner , @railway_direction = railway_line , train_owner , railway_direction @delay = delay @starting_station , @terminal_station = starting_station , terminal_station @from_station , @to_station = from_station , to_station # set_train_name end |
Instance Attribute Details
#dc_date ⇒ DateTime (readonly)
データ生成時刻 - xsd:dateTime(ISO8601 日付時刻形式をもとに生成した DateTime のインスタンス)
47 48 49 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 47 def dc_date @dc_date end |
#delay ⇒ Integer (readonly)
5分未満は切り捨て
遅延時間(秒) - xsd:integer
98 99 100 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 98 def delay @delay end |
#frequency ⇒ Integer (readonly)
指定された秒数以降にリクエストを行うことで、最新値が取得される。
更新頻度(秒) - xsd:integer
58 59 60 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 58 def frequency @frequency end |
#from_station ⇒ String (readonly)
列車が出発した駅 - odpt:Station
104 105 106 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 104 def from_station @from_station end |
#railway_direction ⇒ String (readonly)
方面 - odpt:RailDirection
91 92 93 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 91 def railway_direction @railway_direction end |
#railway_line ⇒ String (readonly)
鉄道路線ID - odpt:Railway
73 74 75 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 73 def railway_line @railway_line end |
#same_as ⇒ String (readonly)
API での命名ルールは「odpt.Train:TokyoMetro.路線名.列車番号」
固有識別子 - URL
41 42 43 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 41 def same_as @same_as end |
#starting_station ⇒ String (readonly)
列車の始発駅 - odpt:Station
81 82 83 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 81 def starting_station @starting_station end |
#terminal_station ⇒ String (readonly)
列車の終着駅 - odpt:Station
85 86 87 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 85 def terminal_station @terminal_station end |
#to_station ⇒ String? (readonly)
列車が向かっている駅 - odpt:Station
109 110 111 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 109 def to_station @to_station end |
#train_name ⇒ Object (readonly)
Returns the value of attribute train_name.
111 112 113 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 111 def train_name @train_name end |
#train_number ⇒ String (readonly)
列車番号 - xsd:string
64 65 66 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 64 def train_number @train_number end |
#train_owner ⇒ String (readonly)
車両の所属会社 - odpt:TrainOwner
77 78 79 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 77 def train_owner @train_owner end |
#train_type ⇒ String (readonly)
各停 (odpt.TrainType:Local) 、急行 (odpt.TrainType:Express) 、快速 (odpt.TrainType:Rapid) 、特急 (odpt.TrainType:LimitedExpress) など
列車種別 - odpt:TrainType
69 70 71 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 69 def train_type @train_type end |
#valid ⇒ DateTime (readonly)
データ保証期限 - xsd:dateTime(ISO8601 日付時刻形式をもとに生成した DateTime のインスタンス)
53 54 55 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 53 def valid @valid end |
Instance Method Details
#actual_delay ⇒ Object
170 171 172 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 170 def actual_delay @delay end |
#before_decorate ⇒ Object
119 120 121 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 119 def before_decorate ::TokyoMetro::Factory::BeforeDecorate::Api::TrainLocation::Info.new( self ) end |
#between_station? ⇒ Boolean
列車が駅間にいるか否かの真偽値(駅間にいる場合は true )
196 197 198 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 196 def between_station? !( now_at_station? ) end |
#decorate(request, railway_line) ⇒ Object
115 116 117 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 115 def decorate( request , railway_line ) ::TokyoMetro::Factory::Decorate::Api::TrainLocation::Info.new( request , self , railway_line ) end |
#delay_instance ⇒ Object
200 201 202 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 200 def delay_instance ::TokyoMetro::Api::TrainLocation::Info::Delay.new( actual_delay ) end |
#delay_now?(delay_minimum_second) ⇒ Boolean
遅延しているか否かを判定するメソッド
181 182 183 184 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 181 def delay_now?( delay_minimum_second ) raise "Error" unless delay_minimum_second >= 0 actual_delay > delay_minimum_second end |
#now_at_station? ⇒ Boolean
列車が駅に停車中か否かの真偽値(駅に停車中の場合は true )
190 191 192 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 190 def now_at_station? @to_station.nil? end |
#on_schedule? ⇒ Boolean
174 175 176 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 174 def on_schedule? actual_delay == 0 end |
#to_h ⇒ Hash
インスタンスの情報をハッシュにして返すメソッド
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/tokyo_metro/api/train_location/info.rb', line 141 def to_h h = Hash.new set_data_to_hash( h , "\@id" , @id_urn ) set_data_to_hash( h , "owl:sameAs" , @same_as ) set_data_to_hash( h , "dc:date" , @dc_date.to_s ) set_data_to_hash( h , "dct:valid" , @valid.to_s ) set_data_to_hash( h , "odpt:frequency" , @frequency ) set_data_to_hash( h , "odpt:railway" , @railway_line ) set_data_to_hash( h , "odpt:railDirection" , @railway_direction ) set_data_to_hash( h , "odpt:trainNumber" , @train_number ) set_data_to_hash( h , "odpt:trainType" , @train_type ) set_data_to_hash( h , "odpt.trainOwner" , @train_owner ) set_data_to_hash( h , "odpt:startingStation" , @starting_sta ) set_data_to_hash( h , "odpt:terminalStation" , @terminal_sta ) set_data_to_hash( h , "odpt:delay" , @delay ) set_data_to_hash( h , "odpt:fromStation" , @from_station ) set_data_to_hash( h , "odpt:toStation" , @to_station ) h end |