Sha256: f33a266f5b1cccd36b8899f98600e3cbda7ab546515e074987a32a1b82cc45ce

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

class TokyoMetro::Factory::Generate::Api::Point::Info::Title < TokyoMetro::Factory::Generate::Api::MetaClass::Info::NotOnTheTopLayer

  include ::TokyoMetro::ClassNameLibrary::Api::Point

  def self.instance_class
    title_class
  end

  private

  def variables
    set_variables
    set_station_name
    [ @station_name , @code , @additional_name , @elevator , @closed ]
  end

  def set_variables
    if /\A(.+?)(?:出入口)+\Z/ === @string
      @station_name = $1
    elsif /\A(.+?)出入口(.+)\Z/ === @string
      @station_name = $1
      @code = $2
      set_variables_in_code
    else
      raise "Error"
    end
   end

  def set_variables_in_code
    if /\A(.+)[((](.+)[))]\Z/ === @code
      @code = $1
      @additional_name = $2
    end

    elevator_regexp = /\Aエレベーター?\Z/

    if elevator_regexp === @code
      @elevator = true
      @code = nil
    elsif elevator_regexp === @additional_name
      @elevator = true
      @additional_name = nil

    elsif @additional_name == "閉"
      @closed = true
      @additional_name = nil
    end
  end

  def set_station_name
    case @station_name
    when "明治神宮前"
      @station_name = "明治神宮前〈原宿〉"
    when "押上"
      @station_name = "押上〈スカイツリー前〉"
    end
  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/point/info/title.rb