Sha256: edf6a053bf5f13c487800542b071f720e69af13a91cbba3f1f10539c2038a9c9

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

class TokyoMetro::Factory::Convert::Customize::Api::StationTimetable::AdditionalInfos::Generate::List < TokyoMetro::Factory::Convert::Common::Api::MetaClass::Fundamental::Updated

  include ::TokyoMetro::Modules::Common::ConvertConstantToClassMethod

  [ :ignored_station_timetables , :replacing_infos ].each do | filename |
    const_set( filename.upcase , ::YAML.load_file( "#{::TokyoMetro.dictionary_dir}/additional_infos/customize/station_timetable/#{filename}.yaml" ) )
  end

  include ::TokyoMetro::ClassNameLibrary::Api::StationTimetable


  def process
    delete_ignored_station_timetables
    replacing_infos
  end

  private

  def delete_ignored_station_timetables
    @object.reject! do | item |
      IGNORED_STATION_TIMETABLES.include?( item.same_as )
    end
  end

  def replacing_infos
    @object.each do | item |
      replacing_infos_of_this_station_timetable = REPLACING_INFOS[ item.same_as ]
      if replacing_infos_of_this_station_timetable.present?

        replacing_name = replacing_infos_of_this_station_timetable[ "replacing_name" ]
        if replacing_name.present?
          item.instance_variable_set( :@same_as , replacing_name )
        end

        replacing_fundamental_infos = replacing_infos_of_this_station_timetable[ "replacing_fundamental_infos" ]
        if replacing_fundamental_infos.present?
          new_ary_of_fundamental_infos = self.class.fundamental_list_class.new( replacing_fundamental_infos.map { | info |
            infos_send_to_new_fundamental_info = [ "stations" , "railway_lines" , "operators" , "railway_directions" ].map { | key | info[ key ] }
            self.class.fundamental_info_class.new( *infos_send_to_new_fundamental_info )
          } )
          item.instance_variable_set( :@fundamental_infos , new_ary_of_fundamental_infos )
        end

      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/factory/convert/customize/api/station_timetable/additional_infos/generate/list.rb