Class: TokyoMetro::Factory::Get::Api::DataSearch::TrainLocation

Inherits:
MetaClass::Search::DataSearch show all
Includes:
ClassNameLibrary::Api::TrainLocation
Defined in:
lib/tokyo_metro/factory/get/api/data_search/train_location.rb

Overview

API から列車ロケーション情報 odpt:Train のデータを取得するための Factory Pattern のクラス

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MetaClass::Fundamental

#get_data

Constructor Details

#initialize(railway_line, id, same_as, train_number, train_type, train_owner, railway_direction, delay, starting_station, terminal_station, from_station, to_station, parse_json, generate_instance, to_inspect) ⇒ TrainLocation

Constructor



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tokyo_metro/factory/get/api/data_search/train_location.rb', line 7

def initialize( railway_line , id , same_as , train_number , train_type , train_owner , railway_direction , delay ,
  starting_station , terminal_station , from_station , to_station ,
  parse_json , generate_instance , to_inspect )

  super( parse_json , generate_instance , to_inspect )
  @railway_line = railway_line

  @id = id
  @same_as = same_as
  @train_number = train_number
  @train_type = train_type
  @train_owner = train_owner
  @railway_direction = railway_direction
  @delay = delay
  @starting_station = starting_station
  @terminal_station = terminal_station
  @from_station = from_station
  @to_station = to_station
end

Class Method Details

.process(http_client, railway_line, id, same_as, train_number, train_type, train_owner, railway_direction, delay, starting_station, terminal_station, from_station, to_station, parse_json, generate_instance, to_inspect) ⇒ Object

API からデータを取得するメソッド

Parameters:

  • http_client (HTTPClient)

    HTTPClient のインスタンス【必須】

  • parse_json (Boolean)

    JSONを配列とするか否かの設定(false の場合は文字列とする)【必須】

  • generate_instance (Boolean)

    データ取得後に Ruby のインスタンスを作成するか否かの設定【必須】

  • to_inspect (Boolean)

    データ取得後にコマンドツールに内容を表示するか否かの設定【必須】



56
57
58
59
60
61
62
63
64
65
# File 'lib/tokyo_metro/factory/get/api/data_search/train_location.rb', line 56

def self.process( http_client , railway_line , id , same_as , train_number , train_type , train_owner , railway_direction , delay ,
  starting_station , terminal_station , from_station , to_station ,
  parse_json , generate_instance , to_inspect )

  info = self.new( railway_line , id , same_as , train_number , train_type , train_owner , railway_direction , delay ,
    starting_station , terminal_station , from_station , to_station ,
    parse_json , generate_instance , to_inspect )

  info.get_data( http_client )
end

Instance Method Details

#parametersHash

HTTPClient に送るパラメーター

Returns:

  • (Hash)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/tokyo_metro/factory/get/api/data_search/train_location.rb', line 29

def parameters
  h = super

  h[ "odpt:railway" ] = @railway_line

  set_parameter_send_to_api( h , "\@id" , @id , String )
  set_parameter_send_to_api( h , "owl:sameAs" , @same_as , String )
  set_parameter_send_to_api( h , "odpt:trainNumber" , @train_number , String )
  set_parameter_send_to_api( h , "odpt:trainType" , @train_type , String )

  set_parameter_send_to_api( h , "odpt.trainOwner" , @train_owner , String )
  set_parameter_send_to_api( h , "odpt:railDirection" , @railway_direction , String )

  set_parameter_send_to_api( h , "odpt:delay" , @delay , Integer )
  set_parameter_send_to_api( h , "odpt:startingStation" , @starting_station , String )
  set_parameter_send_to_api( h , "odpt:terminalStation" , @terminal_station , String )
  set_parameter_send_to_api( h , "odpt:fromStation" , @from_station , String )
  set_parameter_send_to_api( h , "odpt:toStation" , @to_station , String )

  h
end