class TokyoMetro::Factory::Convert::Customize::Api::TrainTimetable::ReplaceStationName::Info
Public Class Methods
new( object , regexp_for_replaced_station , replacing_string )
click to toggle source
Calls superclass method
TokyoMetro::Factory::Convert::Common::Api::MetaClass::Fundamental::new
# File lib/tokyo_metro/factory/convert/customize/api/train_timetable/replace_station_name/info.rb, line 3 def initialize( object , regexp_for_replaced_station , replacing_string ) super( object ) @regexp_for_replaced_station = regexp_for_replaced_station @replacing_string = replacing_string end
Public Instance Methods
process()
click to toggle source
# File lib/tokyo_metro/factory/convert/customize/api/train_timetable/replace_station_name/info.rb, line 9 def process object.valid_timetables.each do | timetable | timetable.each do | station_time | [ :arrival_station , :departure_station ].each do | method | station_name = station_time.send( method ) if station_name.present? and @regexp_for_replaced_station === station_name station_name_new = station_name.gsub( @regexp_for_replaced_station , @replacing_string ) station_time.instance_variable_set( "@#{ method }" , station_name_new ) end end end end end