Class: TokyoMetro::Api::Station::Info

Overview

個別の駅情報を扱うクラス

Defined Under Namespace

Modules: Common, ConnectingRailwayLine, Exit, LinkToPassengerSurvey

メタデータ (For developers) collapse

地理情報 (For developers) collapse

一般の情報 collapse

駅情報の取得 collapse

Instance Method Summary collapse

Methods included from Modules::Common::ToFactory::Seed::Info

#seed

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::Api::Info::ToJson

#to_json

Constructor Details

#initialize(id_urn, same_as, title, dc_date, geo_long, geo_lat, region, operator, railway_line, connecting_railway_lines, facility, passenger_survey, station_code, exit_list) ⇒ Info

Constructor



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tokyo_metro/api/station/info.rb', line 17

def initialize( id_urn , same_as , title , dc_date , geo_long , geo_lat , region ,
    operator , railway_line , connecting_railway_lines , facility , passenger_survey , station_code , exit_list )
  @id_urn = id_urn
  @same_as = same_as
  @title , @dc_date = title , dc_date

  @geo_long = geo_long
  @geo_lat = geo_lat
  @region = region

  @operator = operator
  @railway_line = railway_line
  @connecting_railway_lines = connecting_railway_lines
  @facility = facility
  @passenger_survey = passenger_survey
  @station_code = station_code
  @exit_list = exit_list
end

Instance Attribute Details

#connecting_railway_lines::Array <odpt:Railway> (readonly)

乗り換え可能路線の一覧

Returns:

  • (::Array <odpt:Railway>)


83
84
85
# File 'lib/tokyo_metro/api/station/info.rb', line 83

def connecting_railway_lines
  @connecting_railway_lines
end

#dc_dateDateTime (readonly)

データ生成時刻 - xsd:dateTime(ISO8601 日付時刻形式をもとに生成した DateTime のインスタンス)

Examples:

2013–01–13T15:10:00+09:00

Returns:

  • (DateTime)


48
49
50
# File 'lib/tokyo_metro/api/station/info.rb', line 48

def dc_date
  @dc_date
end

#exit_listInfo::Exit::List <ug:Poi> (readonly)

駅出入口を表すオブジェクトへのリンク - odpt:exit

Returns:



99
100
101
# File 'lib/tokyo_metro/api/station/info.rb', line 99

def exit_list
  @exit_list
end

#facility::Array <odpt:StationFacility> (readonly)

駅施設を表すオブジェクトのURI - odpt:facility

Returns:

  • (::Array <odpt:StationFacility>)


87
88
89
# File 'lib/tokyo_metro/api/station/info.rb', line 87

def facility
  @facility
end

#geo_latFloat (readonly) Also known as: latitude

代表点の緯度(10進表記)

Returns:

  • (Float)


58
59
60
# File 'lib/tokyo_metro/api/station/info.rb', line 58

def geo_lat
  @geo_lat
end

#geo_longFloat (readonly) Also known as: longitude

代表点の経度(10進表記)

Returns:

  • (Float)


54
55
56
# File 'lib/tokyo_metro/api/station/info.rb', line 54

def geo_long
  @geo_long
end

#id_urnObject (readonly)

Returns the value of attribute id_urn.



37
38
39
# File 'lib/tokyo_metro/api/station/info.rb', line 37

def id_urn
  @id_urn
end

#operatorString (readonly)

管理会社 - odpt:operator

Returns:

  • (String)


75
76
77
# File 'lib/tokyo_metro/api/station/info.rb', line 75

def operator
  @operator
end

#passenger_surveyInfo::LinkToPassengerSurvey::List <odpt:PassengerSurvey> (readonly)

駅乗降人員数を表すオブジェクトへのリンク - odpt:passengerSurvey

Returns:



91
92
93
# File 'lib/tokyo_metro/api/station/info.rb', line 91

def passenger_survey
  @passenger_survey
end

#railway_lineString (readonly)

鉄道路線ID - odpt:Railway

Returns:

  • (String)


79
80
81
# File 'lib/tokyo_metro/api/station/info.rb', line 79

def railway_line
  @railway_line
end

#regionString (readonly) Also known as: geo_json

Note:

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

Note:

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

Note:

取得される GeoJSON は、駅構内に入線する路線の中央点を取ったPOINTとなる

駅代表点のデータを GeoJSON で取得するためのURL <ug:region - odpt:GeoDocument>

Returns:

  • (String)


65
66
67
# File 'lib/tokyo_metro/api/station/info.rb', line 65

def region
  @region
end

#same_asString (readonly)

Note:

API での命名ルールは「odpt.Station:TokyoMetro.路線名.駅名」

固有識別子 - URL

Returns:

  • (String)


42
43
44
# File 'lib/tokyo_metro/api/station/info.rb', line 42

def same_as
  @same_as
end

#station_codeString (readonly)

駅コード - odpt:stationCode

Returns:

  • (String)


95
96
97
# File 'lib/tokyo_metro/api/station/info.rb', line 95

def station_code
  @station_code
end

#titleString (readonly) Also known as: station

駅名 - dc:title

Returns:

  • (String)


71
72
73
# File 'lib/tokyo_metro/api/station/info.rb', line 71

def title
  @title
end

Instance Method Details

#basenameObject



145
146
147
# File 'lib/tokyo_metro/api/station/info.rb', line 145

def basename
  @same_as.gsub( /\Aodpt\.Station\:TokyoMetro\.[[:alpha:]]+\.([[:alpha:]]+)\Z/ ) { $1 }
end

#basename_to_displayObject



149
150
151
# File 'lib/tokyo_metro/api/station/info.rb', line 149

def basename_to_display
  self.basename.gsub( /(?<=[a-z])([A-Z])/ ) { "-#{$1.downcase}" }
end

#seed_connecting_railway_lines(indent) ⇒ Object



164
165
166
# File 'lib/tokyo_metro/api/station/info.rb', line 164

def seed_connecting_railway_lines( indent )
  @connecting_railway_lines.try( :seed , station_info_id , indent )
end

#seed_exits(indent) ⇒ Object



168
169
170
# File 'lib/tokyo_metro/api/station/info.rb', line 168

def seed_exits( indent )
  @exit_list.try( :seed , station_info_id , indent )
end


172
173
174
# File 'lib/tokyo_metro/api/station/info.rb', line 172

def seed_link_to_passenger_surveys( indent )
  @passenger_survey.try( :seed , station_info_id , indent )
end

#title_shift_jisObject Also known as: name_ja



153
154
155
156
157
158
159
160
# File 'lib/tokyo_metro/api/station/info.rb', line 153

def title_shift_jis
  case @title
  when "麴町"
    "麹町"
  else
    @title
  end
end

#to_hHash

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

Returns:

  • (Hash)


120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/tokyo_metro/api/station/info.rb', line 120

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:date" , @dc_date.to_s )
  set_data_to_hash( h , "ug:region" , @region )

  set_data_to_hash( h , "odpt:operator" , @operator )
  set_data_to_hash( h , "odpt:railway" , @railway_line )

  set_data_to_hash( h , "odpt:stationCode" , @station_code )
  set_data_to_hash( h , "dc:title" , @title )

  set_data_to_hash( h , "geo:long" , @geo_long )
  set_data_to_hash( h , "geo:lat" , @geo_lat )

  set_data_to_hash( h , "odpt:connectingRailway" , @connecting_railway_lines )
  set_data_to_hash( h , "odpt:facility" , @facility )
  set_data_to_hash( h , "odpt:passengerSurvey" , @passenger_survey )
  set_data_to_hash( h , "odpt:exit" , @exit_list )

  h
end

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

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

Parameters:

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

    ] インデントの幅

Returns:

  • (String)


112
113
114
# File 'lib/tokyo_metro/api/station/info.rb', line 112

def to_s( indent = 0 )
  to_s_with_array( [ "odpt:connectingRailway" , "odpt:passengerSurvey" , "odpt:exit" ] , indent )
end