Class: Translink::Page::Trip::StopTime

Inherits:
Object
  • Object
show all
Defined in:
lib/translink/page/trip.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arrival_timeObject

String

The time the vehicle arrives at the stop.



34
35
36
# File 'lib/translink/page/trip.rb', line 34

def arrival_time
  @arrival_time
end

#stop_pageObject

Page::Trip::Stop

Stop associated with the arrival_time.



35
36
37
# File 'lib/translink/page/trip.rb', line 35

def stop_page
  @stop_page
end

#stop_sequenceObject

Integer

Order in which this stop is visited in the trip.



36
37
38
# File 'lib/translink/page/trip.rb', line 36

def stop_sequence
  @stop_sequence
end

Instance Method Details

#departure_timeString

Time vehicle starts from the stop. Translink doesn’t provide an explicit departure_time so we use the arrival_time.

Returns:

  • (String)

    Eg: “10:00 A.M.”



42
43
44
# File 'lib/translink/page/trip.rb', line 42

def departure_time
  arrival_time
end

#html!(node_set) ⇒ Page::Trip::Stop

Sets attributes by extracting attributes from the HTML fragment.

Parameters:

  • node_set (Nokogiri::XML::NodeSet)

    The HTML fragment to search.

Returns:



50
51
52
53
54
# File 'lib/translink/page/trip.rb', line 50

def html! node_set
  @stop_page    = Stop.new.html! node_set
  @arrival_time = node_set.search('td').first.text.sub('.', ':').sub(/(a|p)(m)$/, ' \1.M.').upcase # "12:25pm" -> "12:25 P.M"
  self
end