Class: TokyoMetro::Api::Fare
- Inherits:
-
MetaClass::NotRealTime
- Object
- MetaClass::Fundamental
- MetaClass::DataSearch
- MetaClass::NotRealTime
- TokyoMetro::Api::Fare
- Defined in:
- lib/tokyo_metro/api/fare.rb
Overview
Note:
2駅間の運賃を表す。
運賃 odpt:RailwayFare を扱うクラス
Defined Under Namespace
クラスメソッド - データの取得・保存 collapse
-
.get(http_client, id_urn: nil, same_as: nil, operator: nil, from_station: nil, to_station: nil, ticket: nil, child_ticket: nil, ic_card: nil, child_ic_card: 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, from_station: nil, to_station: nil, ticket: nil, child_ticket: nil, ic_card: nil, child_ic_card: nil, to_inspect: false) ⇒ nil
運賃の情報を取得し保存するメソッド.
テスト collapse
-
.get_test(http_client, from) ⇒ nil
データ取得のテスト.
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, from_station: nil, to_station: nil, ticket: nil, child_ticket: nil, ic_card: nil, child_ic_card: nil, parse_json: false, generate_instance: false, to_inspect: false) ⇒ ::Array
運賃の情報を取得するメソッド
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tokyo_metro/api/fare.rb', line 26 def self.get( http_client , id_urn: nil , same_as: nil , operator: nil , from_station: nil , to_station: nil , ticket: nil , child_ticket: nil , ic_card: nil , child_ic_card: nil , parse_json: false , generate_instance: false , to_inspect: false ) factory_for_getting.process( http_client , id_urn , same_as , operator , from_station , to_station , ticket , child_ticket , ic_card , child_ic_card , parse_json , generate_instance , to_inspect ) end |
.get_test(http_client, from) ⇒ nil
データ取得のテスト
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/tokyo_metro/api/fare.rb', line 80 def self.get_test( http_client , from ) puts "● Fare (from #{from})" data = get( http_client , from_station: from , to_station: nil , # id_urn: nil , same_as: nil , operator: nil , # ticket: "240" , # child_ticket: nil , ic_card: nil , child_ic_card: nil , to_inspect: true , parse_json: true , generate_instance: true ) puts data.sort_by_fare.to_strf end |
.save(http_client, filename, file_type: :yaml, id_urn: nil, same_as: nil, operator: nil, from_station: nil, to_station: nil, ticket: nil, child_ticket: nil, ic_card: nil, child_ic_card: nil, to_inspect: false) ⇒ nil
運賃の情報を取得し保存するメソッド
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tokyo_metro/api/fare.rb', line 52 def self.save( http_client , filename , file_type: :yaml , id_urn: nil , same_as: nil , operator: nil , from_station: nil , to_station: nil , ticket: nil , child_ticket: nil , ic_card: nil , child_ic_card: nil , to_inspect: false ) data = get( http_client , id_urn: id_urn , same_as: same_as , operator: operator , from_station: from_station , to_station: to_station , ticket: ticket , child_ticket: child_ticket , ic_card: ic_card , child_ic_card: child_ic_card , 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 |