Class: TokyoMetro::Api::RailwayLine::Info

Overview

Note:

DB への流し込みは、Static::RailwayLine::Info#seed (Modules::Common::ToFactory::Seed::Info で定義)で行う。 関連: Factory::Seed::Static::RailwayLine::Info

個別の路線情報を扱うクラス

Defined Under Namespace

Modules: MetaClass, StationOrder, TravelTime, WomenOnlyCar

メタデータ (For developers) collapse

一般の情報 collapse

Constructor collapse

路線情報の取得 collapse

Methods included from Modules::Common::Info::RailwayLine::BranchLine

#branch_railway_line?

Methods included from Modules::Common::Info::RailwayLine

#is_not_branch_railway_line, #method_missing

Methods included from Modules::Common::Info::Decision::RailwayLine

#on_marunouchi_line_including_branch?, #on_namboku_or_toei_mita_line?, #on_toei_mita_line?, #on_yurakucho_or_fukutoshin_line?

Methods included from Modules::Common::Info::Decision::Operator

#operated_by_tokyo_metro?, #tokyo_metro?

Methods included from Modules::Common::Info::Decision::SameAs

#same_as?

Methods included from Modules::Api::Info::ToJson

#to_json

Constructor Details

#initialize(id_urn, same_as, title, region, operator, railway_line_code, station_order, travel_time, women_only_car, dc_date) ⇒ Info

Constructor



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 22

def initialize( id_urn , same_as , title , region , operator , railway_line_code ,
  station_order , travel_time , women_only_car , dc_date )
  @id_urn = id_urn
  @same_as = same_as
  @title = title
  @region = region
  @operator = operator
  @railway_line_code = railway_line_code
  @station_order = station_order
  @travel_time = travel_time
  @women_only_car = women_only_car
  @dc_date = dc_date
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TokyoMetro::Modules::Common::Info::RailwayLine

Instance Attribute Details

#dc_dateObject (readonly)

Returns the value of attribute dc_date.



82
83
84
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 82

def dc_date
  @dc_date
end

#id_urnString (readonly)

Note:

支線には別IDを割り当てる

固有識別子 (ucode)

Returns:

  • (String)


43
44
45
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 43

def id_urn
  @id_urn
end

#operatorString (readonly)

運行会社 <odpt:operator - odpt:Operator>

Returns:

  • (String)


59
60
61
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 59

def operator
  @operator
end

#railway_line_codeString (readonly)

路線コード <odpt:lineCode - xsd:string>

Returns:

  • (String)


68
69
70
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 68

def railway_line_code
  @railway_line_code
end

#regionString (readonly) Also known as: geo_json

Note:

ここで ug:region が指し示すURLは、路線形状データを GeoJSON で取得するためのURLとなる。

Note:

GeoJSON 取得には、ug:regionに記載されているURLに加えて、アクセストークンの付与が必要である。

路線形状データを Geojson で取得するためのURL <ug:region - odpt:GeoDocument>

Returns:

  • (String)


53
54
55
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 53

def region
  @region
end

#same_asObject (readonly)

Note:

命名ルールは「odpt.Railway:TokyoMetro.路線名」

固有識別子 <owl:sameAs - URL>



47
48
49
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 47

def same_as
  @same_as
end

#station_orderStationOrder::List <StationOrder::Info> (readonly)

駅の順序 <odpt:stationOrder - Array>



72
73
74
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 72

def station_order
  @station_order
end

#titleString (readonly)

Note:

運行系統名 dc:title は、一般的に用いられる路線名・愛称を示す。

運行系統名 <dc:title - xsd:string>

Returns:

  • (String)


64
65
66
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 64

def title
  @title
end

#travel_timeTravelTime::List <TravelTime::Info> (readonly)

駅間の標準所要時間リスト <odpt:travelTime - Array>



76
77
78
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 76

def travel_time
  @travel_time
end

#women_only_carWomenOnlyCar::List <WomenOnlyCar::Info> (readonly)

女性専用車両情報のリスト <odpt:womenOnlyCar - Array (odpt:WomenOnlyCar)>



80
81
82
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 80

def women_only_car
  @women_only_car
end

Instance Method Details

#railway_line_code_for_filenameObject

Note:

丸ノ内線の「M」と「m」の競合を防ぐため

ファイル名に使用する路線名



90
91
92
93
94
95
96
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 90

def railway_line_code_for_filename
  if /\A[a-z]/ === railway_line_code
    "#{railway_line_code.capitalize}_small"
  else
    railway_line_code
  end
end

#railway_line_idObject



140
141
142
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 140

def railway_line_id
  ::RailwayLine.find_by( same_as: @same_as ).id
end

#seed_station_order_infosObject

Note:

TokyoMetro::Api::RailwayLine::Info::StationOrder::List#seed を実行

Note:


128
129
130
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 128

def seed_station_order_infos
  @station_order.seed
end

#seed_travel_time_infosObject



132
133
134
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 132

def seed_travel_time_infos
  @travel_time.try( :seed , railway_line_id )
end

#seed_women_only_car_infosObject



136
137
138
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 136

def seed_women_only_car_infos
  @women_only_car.try( :seed , railway_line_id )
end

#to_hHash

インスタンスの情報をハッシュにして返すメソッド

Returns:

  • (Hash)


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 109

def to_h
  h = Hash.new
  set_data_to_hash( h , "\@id" , @id_urn )
  set_data_to_hash( h , "owl:sameAs" , @same_as )
  set_data_to_hash( h , "dc:title" , @title )
  set_data_to_hash( h , "ug:region" , @region )
  set_data_to_hash( h , "odpt:operator" , @operator )
  set_data_to_hash( h , "odpt:lineCode" , @railway_line_code )

  set_data_to_hash( h , "odpt:stationOrder" , @station_order )
  set_data_to_hash( h , "odpt:travelTime" , @travel_time )
  set_data_to_hash( h , "odpt:womenOnlyCar" , @women_only_car )
  set_data_to_hash( h , "dc:date" , @dc_date )

  h
end

#to_s(indent = 0) ⇒ String Also known as: to_strf

インスタンスの情報を文字列にして返すメソッド

Parameters:

  • indent (Integer (>=0) (defaults to: 0)

    ] インデントの幅

Returns:

  • (String)


101
102
103
# File 'lib/tokyo_metro/api/railway_line/info.rb', line 101

def to_s( indent = 0 )
  to_s_with_array( [ "odpt:stationOrder" , "odpt:travelTime" , "odpt:womenOnlyCar" ] , indent )
end