Sha256: 1125d256cf168b59eabb8d23de737223276c4c4e33555f483270bb15d4f4b173

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

# API から取得したハッシュからインスタンスを生成するための Factory Pattern のクラス(メタクラス)
class TokyoMetro::Factory::Generate::Api::TrainTimetable::Info::StationTime::Info < TokyoMetro::Factory::Generate::Api::MetaClass::Info::NotOnTheTopLayer

  include ::TokyoMetro::ClassNameLibrary::Api::TrainTimetable

  def variables
    arrival_time = set_time_variable( "odpt:arrivalTime" )
    arrival_station = @hash[ "odpt:arrivalStation" ]
    departure_time = set_time_variable( "odpt:departureTime" )
    departure_station = @hash[ "odpt:departureStation" ]

    [ arrival_time , arrival_station , departure_time , departure_station ]
  end

  def self.instance_class
    station_time_info_class
  end

  private

  def set_time_variable( k )
    if @hash[ k ].present?
      ::DateTime.convert_str( @hash[ k ] )
    else
      nil
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/factory/generate/api/train_timetable/info/station_time/info.rb