Class: TokyoMetro::Factory::YamlStationList::EachStation
- Inherits:
-
Object
- Object
- TokyoMetro::Factory::YamlStationList::EachStation
- Defined in:
- lib/tokyo_metro/factory/yaml_station_list/each_station.rb
Overview
駅名のリストを作成するときの各駅の情報を扱うクラス
Constant Summary collapse
- REGEXP_FOR_SPLIT =
スラッシュ(前後に空白がある場合はそれも含む)にマッチする正規表現
/ *\/ */
Instance Method Summary collapse
-
#initialize(key_of_h1, header, contents) ⇒ EachStation
constructor
Constructor.
-
#last_index_of_station_info ⇒ Object
駅情報の最後の index(この先は停車駅情報).
- #station_facility_info? ⇒ Boolean
- #station_info? ⇒ Boolean
- #to_hash_of_hash ⇒ Object
Constructor Details
#initialize(key_of_h1, header, contents) ⇒ EachStation
Constructor
8 9 10 11 12 |
# File 'lib/tokyo_metro/factory/yaml_station_list/each_station.rb', line 8 def initialize( key_of_h1 , header , contents ) @key = key_of_h1 @header = header @contents = contents end |
Instance Method Details
#last_index_of_station_info ⇒ Object
駅情報の最後の index(この先は停車駅情報)
53 54 55 56 57 58 59 |
# File 'lib/tokyo_metro/factory/yaml_station_list/each_station.rb', line 53 def last_index_of_station_info if @header.include?( "station_code" ) @header.index( "station_code" ) else @header.index( "name_en" ) end end |
#station_facility_info? ⇒ Boolean
18 19 20 |
# File 'lib/tokyo_metro/factory/yaml_station_list/each_station.rb', line 18 def station_facility_info? /\Aodpt\.StationFacility\:/ === @key end |
#station_info? ⇒ Boolean
14 15 16 |
# File 'lib/tokyo_metro/factory/yaml_station_list/each_station.rb', line 14 def station_info? /\Aodpt\.Station\:/ === @key end |
#to_hash_of_hash ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tokyo_metro/factory/yaml_station_list/each_station.rb', line 22 def to_hash_of_hash h = Hash.new @contents.each_with_index do | content , i | title = @header[ i ] border_index = self.last_index_of_station_info if i <= border_index # inspect_of_custom_alias( title , content ) h[ title ] = set_content( title , content ) else case title when "administrator" , "other_operator" h[ title ] = set_content( title , content ) else set_train_types_to_hash( h , title , content ) end end end return h end |