Class: Gtfskit::Dataset::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/gtfskit/dataset/factory.rb

Constant Summary collapse

DATASET =
{
  :agency         => Gtfskit::Dataset::Agency,
  :calendar       => Gtfskit::Dataset::Calendar,
  :calendar_date  => Gtfskit::Dataset::CalendarDate,
  :calendar_dates => Gtfskit::Dataset::CalendarDate,
  :route          => Gtfskit::Dataset::Route,
  :routes         => Gtfskit::Dataset::Route,
  :stop           => Gtfskit::Dataset::Stop,
  :stops          => Gtfskit::Dataset::Stop,
  :stop_time      => Gtfskit::Dataset::StopTime,
  :stop_times     => Gtfskit::Dataset::StopTime,
  :trip           => Gtfskit::Dataset::Trip,
  :trips          => Gtfskit::Dataset::Trip
}

Class Method Summary collapse

Class Method Details

.initialize_from(dataset:, **fields) ⇒ Object

Raises:

  • (NameError)


22
23
24
25
26
# File 'lib/gtfskit/dataset/factory.rb', line 22

def initialize_from(dataset:, **fields)
  klass = DATASET[dataset.to_sym]
  raise NameError, "Invalid dataset '#{dataset}' passed to factory.", caller if klass.nil?
  klass.new(**fields)
end