Class: Translink::Model::Trip

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

Instance Method Summary collapse

Instance Method Details

#add_stop_time_from_stop_time_page(stop_time_page) ⇒ void

This method returns an undefined value.

Creates a Model::StopTime record and associates it with this trip.

Parameters:

  • stop_time_page (Page::Stop::StopTime)

    HTML page representing the stop-time.



27
28
29
30
31
32
33
# File 'lib/translink/model/trip.rb', line 27

def add_stop_time_from_stop_time_page stop_time_page
  StopTime.new.tap do |stop_time|
    stop_time.trip = self
    stop_time.stop_time_page! stop_time_page
    stop_time.save
  end
end

#add_stop_times_from_stop_time_pages(stop_time_pages) ⇒ Object



35
36
37
38
39
# File 'lib/translink/model/trip.rb', line 35

def add_stop_times_from_stop_time_pages stop_time_pages
  stop_time_pages.map do |stop_time_page|
    add_stop_time_from_stop_time_page stop_time_page
  end
end

#trip_page!(trip_page) ⇒ void

This method returns an undefined value.

Sets properties from the given trip_page.

Parameters:

  • trip_page (Trip::Page)

    HTML page that represents the trip.



45
46
47
48
49
# File 'lib/translink/model/trip.rb', line 45

def trip_page! trip_page
  self.id         = trip_page.trip_id
  self.direction  = trip_page.direction
  self.headsign   = trip_page.headsign
end