Sha256: d577d699a1ce970a4b0bf0409d371298bece57de4c5e0b2a4addd94515cbf203

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

class TokyoMetro::Factory::Convert::Patch::Api::TrainLocation::ChiyodaMainLine::Info < TokyoMetro::Factory::Convert::Common::Api::MetaClass::Fundamental::Normal

  def process
    convert_invalid_station_name_of_chiyoda_main_line_train
  end

  private

  def convert_invalid_station_name_of_chiyoda_main_line_train
    if object.chiyoda_line? and starting_on_yoyogi_uehara_side?
      if invalid_chiyoda_main_line_train_terminating_at_kita_ayase?

        if object.limited_express_or_romance_car?
          set_terminal_station_nil
        else
          set_terminal_station_ayase
        end

      elsif invalid_chiyoda_main_line_train_terminating_at_invalid_seijo_gakuen_mae?
        set_terminal_station_nil
      end
    end
  end

  def invalid_chiyoda_main_line_train_terminating_at_kita_ayase?
     object.terminating_at_kita_ayase_on_chiyoda_main_line?
  end

  def invalid_chiyoda_main_line_train_terminating_at_invalid_seijo_gakuen_mae?
    object.terminal_station == "odpt.Station:TokyoMetro.Chiyoda成城学園前"
  end

  def starting_on_yoyogi_uehara_side?
    object.starting_at_yoyogi_uehara? or object.starting_on_odakyu_line? or object.starting_on_hakone_tozan_line?
  end

  def set_terminal_station_ayase
    regexp = /(?<=TokyoMetro\.Chiyoda\.)Kita(?=Ayase)/
    puts "=" * 4 + " " + "invalid_chiyoda_main_line_train_terminating_at_kita_ayase"
    puts object.id_urn
    puts object.same_as
    object.instance_variable_set( :@terminal_station , object.terminal_station.gsub( regexp , "" ) )
  end

  def set_terminal_station_nil
    object.instance_variable_set( :@terminal_station , nil )
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/factory/convert/patch/api/train_location/chiyoda_main_line/info.rb