Sha256: 2ad26bcecfd3e464693ef66c786afe7cdd8ccd6a727897b2215858ec1bda81f1

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

class TokyoMetro::Factory::Convert::Customize::Api::StationTimetable::ChiyodaBranchLine::Info < TokyoMetro::Factory::Convert::Common::Api::MetaClass::Fundamental::Normal

  REGEXP = /(?<=\Aodpt\.StationTimetable\:TokyoMetro\.)Chiyoda(?=\.(?:KitaAyase\.Ayase|Ayase\.KitaAyase)\Z)/

  def process
    if to_convert?
      convert_railway_line_name
      set_refinement_module_to_fundamental_infos
      convert_fundamental_infos
    end
  end

  private

  # @note @railway_line を "odpt.Railway:TokyoMetro.ChiyodaBranchLine" で統一する。
  def to_convert?
    @object.same_as?( REGEXP )
  end

  def convert_railway_line_name
    @object.instance_variable_set( :@same_as , @object.same_as.gsub( REGEXP , "ChiyodaBranch" ) )
  end

  def set_refinement_module_to_fundamental_infos
    class << @object.fundamental_infos
      include ::TokyoMetro::Refinement::Api::StationTimetable::Info::Fundamental::List
    end
  end

  def convert_fundamental_infos
    @object.fundamental_infos.convert_railway_lines!( /(?<=\Aodpt\.Railway\:TokyoMetro\.)Chiyoda(?:Branch)?\Z/ , "ChiyodaBranch" )
    @object.fundamental_infos.convert_stations!( /(?<=\Aodpt\.Station\:TokyoMetro\.)Chiyoda(?:Branch)?(?=\.(?:Kita)?Ayase\Z)/ , "ChiyodaBranch" )
  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/chiyoda_branch_line/info.rb