Class: TokyoMetro::Factory::Generate::Api::Fare::Info

Inherits:
MetaClass::Info::Fundamental show all
Includes:
ClassNameLibrary::Api::Fare
Defined in:
lib/tokyo_metro/factory/generate/api/fare/info.rb

Overview

API から取得したハッシュからインスタンスを生成するための Factory Pattern のクラス(メタクラス)

Instance Method Summary collapse

Methods inherited from MetaClass::Info::Fundamental

#generate, #initialize, instance_class, process, #to_check_validity?

Constructor Details

This class inherits a constructor from TokyoMetro::Factory::Generate::Api::MetaClass::Info::Fundamental

Instance Method Details

#variables::Array

Info クラスに送る変数のリスト

Returns:

  • (::Array)


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tokyo_metro/factory/generate/api/fare/info.rb', line 8

def variables
  id = @hash[ "\@id" ]
  same_as = @hash[ "owl:sameAs" ]
  dc_date = DateTime.parse( @hash[ "dc:date" ] )
  operator = @hash[ "odpt:operator" ]
  from_station = @hash[ "odpt:fromStation" ]
  to_station = @hash[ "odpt:toStation" ]

  fares = [ "odpt:ticketFare" , "odpt:childTicketFare" , "odpt:icCardFare" , "odpt:childIcCardFare" ].map { | key | @hash[ key ] }
  normal_fare = ::TokyoMetro::Static.normal_fare.select_fare( *fares )

  [ id , same_as , dc_date , operator , from_station , to_station , normal_fare ]
end