Class: Translink::Model::Route

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/translink/model/route.rb

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • route_pate (Page::Route)

    HTML page that represents the route.

Returns:



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.

Parameters:

  • trip_page (Page::Trip)

    HTML page that represents the trip.

Returns:



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