Class: TokyoMetro::Factory::Get::Api::MetaClass::Fundamental
- Inherits:
-
Object
- Object
- TokyoMetro::Factory::Get::Api::MetaClass::Fundamental
- Includes:
- OdptCommon::CalcTime
- Defined in:
- lib/tokyo_metro/factory/get/api/meta_class/fundamental.rb
Overview
API からデータを取得するための Factory Pattern のクラス(最上位クラス)
Defined Under Namespace
Modules: Generator
Instance Method Summary collapse
-
#get_data(http_client) ⇒ ::Array <Hash>, String
API からデータを取得するメソッド.
-
#initialize(parse_json, generate_instance, to_inspect) ⇒ Fundamental
constructor
Constructor.
Constructor Details
#initialize(parse_json, generate_instance, to_inspect) ⇒ Fundamental
Note:
generate_instance を true にする場合は、parse_json も true にしなければならない。
Constructor
10 11 12 13 14 15 16 17 |
# File 'lib/tokyo_metro/factory/get/api/meta_class/fundamental.rb', line 10 def initialize( parse_json , generate_instance , to_inspect ) if generate_instance and !( parse_json ) raise "Error: If you want to generate instance, you must set \"generate_instance\" to true and \"parse_json\" to true." end @parse_json = parse_json @generate_instance = generate_instance @to_inspect = to_inspect end |
Instance Method Details
#get_data(http_client) ⇒ ::Array <Hash>, String
API からデータを取得するメソッド
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tokyo_metro/factory/get/api/meta_class/fundamental.rb', line 23 def get_data( http_client ) check_validity_of_settings( http_client ) if @to_inspect time_begin = Time.now # progress_bar = ::ForRails::Progress.new # progress_bar.display( parameters_to_strf ) puts "-" * 128 puts "" puts parameters_to_strf puts "" end response = response_from_api( http_client ) if @to_inspect t = calc_time( time_begin ) puts "Download: #{t} sec" puts "" end process_response( response ) end |