Class: TokyoMetro::Api::PassengerSurvey
- Inherits:
-
MetaClass::NotRealTime
- Object
- MetaClass::Fundamental
- MetaClass::DataSearch
- MetaClass::NotRealTime
- TokyoMetro::Api::PassengerSurvey
- Includes:
- ClassNameLibrary::Api::PassengerSurvey
- Defined in:
- lib/tokyo_metro/api/passenger_survey.rb
Overview
駅乗降人員数 odpt:PassengerSurvey を扱うクラス
Defined Under Namespace
クラスメソッド - データの取得・保存 collapse
-
.get(http_client, id_urn: nil, same_as: nil, operator: nil, survey_year: nil, parse_json: false, generate_instance: false, to_inspect: false) ⇒ ::Array
駅施設情報を取得するメソッド.
-
.save(http_client, filename, file_type: :yaml, id_urn: nil, same_as: nil, operator: nil, survey_year: nil, to_inspect: false) ⇒ nil
駅施設情報を取得し保存するメソッド.
テスト collapse
Methods inherited from MetaClass::Fundamental
factory_for_generating_from_saved_file
Class Method Details
.get(http_client, id_urn: nil, same_as: nil, operator: nil, survey_year: nil, parse_json: false, generate_instance: false, to_inspect: false) ⇒ ::Array
駅施設情報を取得するメソッド
21 22 23 24 25 26 27 28 |
# File 'lib/tokyo_metro/api/passenger_survey.rb', line 21 def self.get( http_client , id_urn: nil , same_as: nil , operator: nil , survey_year: nil , parse_json: false , generate_instance: false , to_inspect: false ) factory_for_getting.process( http_client , id_urn , same_as , operator , survey_year , parse_json , generate_instance , to_inspect ) end |
.get_test(http_client, survey_year: nil) ⇒ nil
データ取得のテスト
63 64 65 66 67 68 69 70 |
# File 'lib/tokyo_metro/api/passenger_survey.rb', line 63 def self.get_test( http_client , survey_year: nil ) puts "● Passenger Survey (as of #{survey_year})" data = get( http_client , survey_year: survey_year , to_inspect: true , parse_json: true , generate_instance: true ) ary = data.select_year( 2013 ).sort_by_passenger_journeys.reverse puts ary.to_strf end |
.save(http_client, filename, file_type: :yaml, id_urn: nil, same_as: nil, operator: nil, survey_year: nil, to_inspect: false) ⇒ nil
駅施設情報を取得し保存するメソッド
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tokyo_metro/api/passenger_survey.rb', line 39 def self.save( http_client , filename , file_type: :yaml , id_urn: nil , same_as: nil , operator: nil , survey_year: nil , to_inspect: false ) data = get( http_client , id_urn: id_urn , same_as: same_as , operator: operator , survey_year: survey_year , parse_json: true , generate_instance: false , to_inspect: to_inspect ) data = eval( data.to_s.gsub( /(?:\r\n|\r)/ ,"\n" ).encode( "UTF-8" ) ) save_data( data , filename , file_type: file_type ) end |