Module: TokyoMetro::Modules::Static::GetName

Included in:
Static::Operator::Info, Static::RailwayLine::Info, Static::StationsInTokyoMetro::Info
Defined in:
lib/tokyo_metro/modules/static/get_name.rb

Overview

路線名などを取得するためのメソッドを提供するモジュール

Instance Method Summary collapse

Instance Method Details

#css_class_name(title, base_method_name) ⇒ String

CSS のクラスの名称を取得するメソッド

Returns:

  • (String)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tokyo_metro/modules/static/get_name.rb', line 6

def css_class_name( title , base_method_name )
  str = self.__send__( base_method_name )
  str = str.gsub( / Line(?:r?)/ , "" )
  str = str.gsub( / Electric/ , "" )
  str = str.gsub( / service/ , "" )
  str = str.gsub( / Company\Z/ , "" )
  str = str.gsub( / Railway\Z/ , "" )
  str = str.gsub( / Corporation/ , "" )
  str = str.gsub( /[Ee]xpress/ , "exp" )
  str = str.gsub( /[\,\(\)]/ , "" )
  str = str.gsub( /[\- ]/ , "_" )
  str = str.gsub( /_{2,}/ , "_" )
  str = str.downcase

  if title.present?
    "#{title}_#{str}"
  else
    str
  end
end

#name_en_inspectObject



35
36
37
# File 'lib/tokyo_metro/modules/static/get_name.rb', line 35

def name_en_inspect
  name_inspect( @name_en )
end

#name_hira_inspectObject



31
32
33
# File 'lib/tokyo_metro/modules/static/get_name.rb', line 31

def name_hira_inspect
  name_inspect( @name_hira )
end

#name_ja_inspectObject



27
28
29
# File 'lib/tokyo_metro/modules/static/get_name.rb', line 27

def name_ja_inspect
  name_inspect( @name_ja )
end