Class: TokyoMetro::Api::Point::Info

Overview

個別の地物情報 ug:Poi のクラス

Defined Under Namespace

Classes: Title

地理情報 (For developers) collapse

一般の情報 collapse

Attributes inherited from MetaClass::Fundamental::Info

#id_urn

駅情報の取得 collapse

Instance Method Summary collapse

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

#to_json

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

#seed

Constructor Details

#initialize(id_urn, title, geo_long, geo_lat, region, ug_floor, category_name) ⇒ Info

Constructor



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tokyo_metro/api/point/info.rb', line 13

def initialize( id_urn , title , geo_long , geo_lat , region , ug_floor , category_name )
  @id_urn = id_urn

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

  @floor = ug_floor
  @category_name = category_name
end

Instance Attribute Details

#category_nameString (readonly) Also known as: category_name_ja

地物のカテゴリ(必ず「出入口」となる) <ugsrv:categoryName - xsd:string>

Returns:

  • (String)


44
45
46
# File 'lib/tokyo_metro/api/point/info.rb', line 44

def category_name
  @category_name
end

#floorInteger (readonly)

地物の階数(高さ情報) <ug:floor - xsd:double>

Returns:

  • (Integer)


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

def floor
  @floor
end

#geo_latFloat (readonly) Also known as: latitude

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

Returns:

  • (Float)


33
34
35
# File 'lib/tokyo_metro/api/point/info.rb', line 33

def geo_lat
  @geo_lat
end

#geo_longFloat (readonly) Also known as: longitude

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

Returns:

  • (Float)


29
30
31
# File 'lib/tokyo_metro/api/point/info.rb', line 29

def geo_long
  @geo_long
end

#regionInteger (readonly) Also known as: geo_json

Note:

取得にはアクセストークンの付与が必要

地物の形状データを GeoJSON で取得するためのURL <ug:region - odpt:GeoDocument>

Returns:

  • (Integer)


38
39
40
# File 'lib/tokyo_metro/api/point/info.rb', line 38

def region
  @region
end

#titleString (readonly)

Note:

エレベータには「エレベータ」という文字列を含む。「出入口」の文字列の後に出口番号が続く。

地物名 <dc:title - xsd:string>

Returns:

  • (String)


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

def title
  @title
end

Instance Method Details

#additional_nameObject Also known as: additional_name_ja



92
93
94
95
96
97
98
99
# File 'lib/tokyo_metro/api/point/info.rb', line 92

def additional_name
  _additional_name = @title.additional_name
  if _additional_name.blank?
    nil
  else
    _additional_name
  end
end

#additional_name_enObject



112
113
114
115
116
# File 'lib/tokyo_metro/api/point/info.rb', line 112

def additional_name_en
  str = ::TokyoMetro::Dictionary.english[ additional_name_ja ]
  #----
  str
end

#category_name_enObject



103
104
105
106
107
108
109
110
# File 'lib/tokyo_metro/api/point/info.rb', line 103

def category_name_en
  str = ::TokyoMetro::Dictionary.english[ category_name_ja ]
  unless str.present?
    raise "Error: The category name of \"#{ @title.to_s }\" is not defined yet."
  end

  str
end

#stationObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/tokyo_metro/api/point/info.rb', line 134

def station
  station_facility_key = nil
  ::TokyoMetro::Api::stations.each do | sta |
    if sta.exit_list.include?( @id_urn )
      if sta.facility.string?
        station_facility_key = sta.facility
      else
        station_facility_key = sta.facility.same_as
      end
      break
    end
  end

  if station_facility_key.present?
    station_facility_key
  else
    raise "Error"
  end
end

#to_hHash

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

Returns:

  • (Hash)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/tokyo_metro/api/point/info.rb', line 74

def to_h
  h = Hash.new

  set_data_to_hash( h , "\@id" , @id_urn )
  set_data_to_hash( h , "dc:title" , @title.to_s )
  set_data_to_hash( h , "ug:region" , @region )

  set_data_to_hash( h , "ug:floor" , @floor )
  set_data_to_hash( h , "ugsrv:categoryName" , @category_name )

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

  h
end

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

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

Parameters:

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

    ] インデントの幅

Returns:

  • (String)


66
67
68
# File 'lib/tokyo_metro/api/point/info.rb', line 66

def to_s( indent = 0 )
  to_s_with_array( [] , indent )
end