Class: Translink::Page::Trip::Stop

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stop_idObject

String

Unique ID.



4
5
6
# File 'lib/translink/page/trip.rb', line 4

def stop_id
  @stop_id
end

#stop_latObject

String

Eg: “27.470677”.



6
7
8
# File 'lib/translink/page/trip.rb', line 6

def stop_lat
  @stop_lat
end

#stop_lonObject

String

Eg: “153.024747”.



7
8
9
# File 'lib/translink/page/trip.rb', line 7

def stop_lon
  @stop_lon
end

#stop_nameObject

String

Eg: “Queen Street station, platform A6”.



5
6
7
# File 'lib/translink/page/trip.rb', line 5

def stop_name
  @stop_name
end

Instance Method Details

#==(other) ⇒ TrueClass, FalseClass

Tests equality with other. Considered equal if stop_id and stop_name are equal.

Parameters:

Returns:

  • (TrueClass, FalseClass)


14
15
16
17
# File 'lib/translink/page/trip.rb', line 14

def == other
  stop_id == other.stop_id &&
  stop_name == other.stop_name
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:



23
24
25
26
27
28
29
30
# File 'lib/translink/page/trip.rb', line 23

def html! node_set
  anchor = node_set.search('td a').first
  anchor['href'] =~ /([^\/]+)$/
  @stop_id = $1
  @stop_name = anchor.text
  @stop_lat, @stop_lon = node_set['data-position'].split(',')
  self
end