Class: TokyoMetro::Api::Station
- Inherits:
-
MetaClass::Hybrid
- Object
- MetaClass::Fundamental
- MetaClass::Hybrid
- TokyoMetro::Api::Station
- Includes:
- ClassNameLibrary::Api::Station
- Defined in:
- lib/tokyo_metro/api/station.rb
Overview
Note:
駅情報 odpt:Stationは、駅の情報を示す。この情報は国土交通省国土数値情報を元に、 施設情報や乗り換え路線などを加筆・修正したものとなる。
駅情報 odpt:Station を扱うクラス
Defined Under Namespace
クラスメソッド - データの取得・保存 collapse
-
.get(http_client, id_urn: nil, same_as: nil, title: nil, operator: nil, railway_line: nil, station_code: nil, parse_json: false, generate_instance: false, to_inspect: false) ⇒ ::Array
駅情報を取得するメソッド.
-
.save(http_client, filename, file_type: :yaml, id_urn: nil, same_as: nil, title: nil, operator: nil, railway_line: nil, station_code: nil, to_inspect: false) ⇒ nil
駅情報を取得し保存するメソッド.
テスト collapse
-
.get_geo_test(http_client, geo_long, geo_lat, radius) ⇒ nil
データ取得のテスト.
-
.get_test(http_client, station) ⇒ nil
データ取得のテスト.
Methods inherited from MetaClass::Fundamental
factory_for_generating_from_saved_file
Class Method Details
.get(http_client, id_urn: nil, same_as: nil, title: nil, operator: nil, railway_line: nil, station_code: nil, parse_json: false, generate_instance: false, to_inspect: false) ⇒ ::Array
駅情報を取得するメソッド
22 23 24 25 26 27 28 |
# File 'lib/tokyo_metro/api/station.rb', line 22 def self.get( http_client , id_urn: nil , same_as: nil , title: nil , operator: nil , railway_line: nil , station_code: nil , parse_json: false , generate_instance: false , to_inspect: false ) factory_for_getting.process( http_client , id_urn , same_as , title , operator , railway_line , station_code , parse_json , generate_instance , to_inspect ) end |
.get_geo_test(http_client, geo_long, geo_lat, radius) ⇒ nil
データ取得のテスト
70 71 72 73 74 75 76 77 78 |
# File 'lib/tokyo_metro/api/station.rb', line 70 def self.get_geo_test( http_client , geo_long , geo_lat , radius ) puts "● #{get_test_title} (geo)" result = get_geo( http_client , geo_long , geo_lat , radius , to_inspect: true , parse_json: true , generate_instance: true ) puts "(#{result.length})" result.sort_by( &:same_as ).each do | rail | puts rail.to_strf puts "" * 2 end end |
.get_test(http_client, station) ⇒ nil
データ取得のテスト
60 61 62 63 64 65 66 |
# File 'lib/tokyo_metro/api/station.rb', line 60 def self.get_test( http_client , station ) station = "odpt.Station:#{station}" puts "● #{get_test_title}" ary = get( http_client , same_as: station , to_inspect: true , parse_json: true , generate_instance: true ) puts "#{station} (#{ary.length})" puts ary.first.to_strf end |
.save(http_client, filename, file_type: :yaml, id_urn: nil, same_as: nil, title: nil, operator: nil, railway_line: nil, station_code: nil, to_inspect: false) ⇒ nil
駅情報を取得し保存するメソッド
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tokyo_metro/api/station.rb', line 41 def self.save( http_client , filename , file_type: :yaml , id_urn: nil , same_as: nil , title: nil , operator: nil , railway_line: nil , station_code: nil , to_inspect: false ) data = get( http_client , id_urn: id_urn , same_as: same_as , title: title , operator: operator , railway_line: railway_line , station_code: station_code , parse_json: true , generate_instance: false , to_inspect: false ) # data = eval( data.to_s.gsub( /(?:\r\n|\r)/ ,"\n" ).encode( "UTF-8" ) ) save_data( data , filename , file_type: file_type ) end |