class TokyoMetro::Api::StationFacility::Info::BarrierFree::ServiceDetail::Info

施設の詳細情報を扱うクラス

Attributes

operation_day[R]

@return [String] 施設利用可能時間やエスカレータの方向が曜日によって変わる場合に、次のいずれかを格納(曜日に依存しない場合は省略)

Weekday, Sunday, Monday, Tuesday Wednesday Thursday Friday Saturday, Holiday
service_end_time[R]

@return [DateTime, String or nil] 施設の利用可能終了時間(いつでも利用できる場合は省略) @note 基本的にはISO8601時刻形式(23:50など)であるが、「終車時」と入る場合もある。

service_start_time[R]

@return [DateTime, String or nil] 施設の利用可能開始時間(いつでも利用できる場合は省略) @note 基本的にはISO8601時刻形式(05:30など)であるが、「始発」と入る場合もある。

Public Class Methods

factory_for_seeding_this_class() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 111
def self.factory_for_seeding_this_class
  factory_for_seeding_barrier_free_facility_service_detail_info
end
factory_for_this_class() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 107
def self.factory_for_this_class
  factory_for_generating_barrier_free_service_detail_from_hash
end
new( service_start_time , service_end_time , operation_day ) click to toggle source

Constructor

# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 10
def initialize( service_start_time , service_end_time , operation_day )
  @service_start_time = service_start_time
  @service_end_time = service_end_time
  @operation_day = operation_day
  # 【注】エスカレーターの方向については、サブクラスのインスタンス変数として定義する。
end

Public Instance Methods

all_day?() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 39
def all_day?
  service_start_before_first_train? and service_end_after_last_train?
end
everyday?() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 43
def everyday?
  @operation_day.nil?
end
has_specific_service_end_time_info?() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 103
def has_specific_service_end_time_info?
  !( service_end_after_last_train? ) and @service_end_time.present?
end
has_specific_service_start_time_info?() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 99
def has_specific_service_start_time_info?
  !( service_start_before_first_train? ) and @service_start_time.present?
end
operation_day_to_s() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 51
def operation_day_to_s
  if everyday?
    "【毎日】"
  else
    " \[#{self.operation_day}\]"
  end
end
operation_days() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 47
def operation_days
  @operation_day.split( "," )
end
service_end_after_last_train?() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 35
def service_end_after_last_train?
  @service_end_time == "終車時"
end
service_start_before_first_train?() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 31
def service_start_before_first_train?
  @service_start_time == "始発"
end
time_to_a() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 73
def time_to_a
  [ @service_start_time , @service_end_time ]
end
time_to_h() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 77
def time_to_h
  h = ::Hash.new

  h[ :service_start_before_first_train ] = service_start_before_first_train?
  h[ :service_start_time_hour ] = nil
  h[ :service_start_time_min ] = nil

  h[ :service_end_time_hour ] = nil
  h[ :service_end_time_min ] = nil
  h[ :service_end_after_last_train ] = service_end_after_last_train?

  if has_specific_service_start_time_info?
    h[ :service_start_time_hour ] , h[ :service_start_time_min ] = @service_start_time.to_array_of_hour_and_min
  end

  if has_specific_service_end_time_info?
    h[ :service_end_time_hour ] , h[ :service_end_time_min ] = @service_end_time.to_array_of_hour_and_min
  end

  h
end
time_to_s( indent = 0 ) click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 59
def time_to_s( indent = 0 )
  if all_day?
    "始発 - 終電"
  else
    self.time_to_a.join( " - " )
  end
end
to_a() click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 69
def to_a
  [ @service_start_time , @service_end_time , @operation_day ]
end
to_s( indent = 0 ) click to toggle source
# File lib/tokyo_metro/api/station_facility/info/barrier_free/service_detail/info.rb, line 27
def to_s( indent = 0 )
  " " * indent + operation_day_to_s + time_to_s
end
Also aliased as: to_strf
to_strf( indent = 0 )
Alias for: to_s