Class: Translink::Model::Route
- Inherits:
-
Object
- Object
- Translink::Model::Route
- Includes:
- DataMapper::Resource
- Defined in:
- lib/translink/model/route.rb
Class Method Summary collapse
-
.find_or_add_route_from_route_page(route_page) ⇒ Model::Route
Route model for the given
route_page
.
Instance Method Summary collapse
-
#add_trip_from_trip_page(trip_page) ⇒ Model::Trip
Create a trip.
Class Method Details
.find_or_add_route_from_route_page(route_page) ⇒ Model::Route
Route model for the given route_page
. Will create the route if it doesn’t exist.
27 28 29 30 31 32 |
# File 'lib/translink/model/route.rb', line 27 def self.find_or_add_route_from_route_page route_page first_or_create :id => route_page.route_id, :short_name => route_page.short_name, :long_name => route_page.long_name, :route_type => route_page.route_type end |
Instance Method Details
#add_trip_from_trip_page(trip_page) ⇒ Model::Trip
Create a trip.
38 39 40 41 42 43 44 |
# File 'lib/translink/model/route.rb', line 38 def add_trip_from_trip_page trip_page Trip.new.tap do |trip| trip.route = self trip.trip_page! trip_page trip.save end end |