Sha256: 792dd07e95add6a261e6402c84143b80a4d122b0e0c89bec5e9d35a2d41cce8d

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

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

  include TokyoMetro::ClassNameLibrary::Api::StationTimetable

  # Info クラスに送る変数のリスト
  # @return [::Array]
  def variables
    id = @hash[ "\@id" ]
    same_as = @hash[ "owl:sameAs" ]
    dc_date = @hash[ "dc:date" ]

    # station = @hash[ "odpt:station" ]
    # railway_line = @hash[ "odpt:railway" ]
    # operator = @hash[ "odpt:operator" ]
    # railway_direction = @hash[ "odpt:railDirection" ]

    fundamental_infos = station_fundamental_infos

    weekdays = generate_timetable_data_from_hash( "odpt:weekdays" )
    saturdays = generate_timetable_data_from_hash( "odpt:saturdays" )
    holidays = generate_timetable_data_from_hash( "odpt:holidays" )

    # [ id , same_as , dc_date , station , railway_line , operator , railway_direction , 
      # weekdays , saturdays , holidays ]

    [ id , same_as , dc_date , fundamental_infos , 
      weekdays , saturdays , holidays ]
  end

  private

  def station_fundamental_infos
    self.class.fundamental_list_class.new( [
      self.class.fundamental_info_class.generate_from_hash( @hash )
    ] )
  end

  def generate_timetable_data_from_hash( key )
    self.class.train_list_class.new( @hash[ key ].map { | train |
      self.class.train_info_class.generate_from_hash( train )
    } )
  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/station_timetable/info.rb