Class: Translink::Page::Trip::Stop
- Inherits:
-
Object
- Object
- Translink::Page::Trip::Stop
- Defined in:
- lib/translink/page/trip.rb
Instance Attribute Summary collapse
-
#stop_id ⇒ Object
- String
-
Unique ID.
-
#stop_lat ⇒ Object
- String
-
Eg: “27.470677”.
-
#stop_lon ⇒ Object
- String
-
Eg: “153.024747”.
-
#stop_name ⇒ Object
- String
-
Eg: “Queen Street station, platform A6”.
Instance Method Summary collapse
-
#==(other) ⇒ TrueClass, FalseClass
Tests equality with
other
. -
#html!(node_set) ⇒ Page::Trip::Stop
Sets attributes by extracting attributes from the HTML fragment.
Instance Attribute Details
#stop_id ⇒ Object
- String
-
Unique ID.
4 5 6 |
# File 'lib/translink/page/trip.rb', line 4 def stop_id @stop_id end |
#stop_lat ⇒ Object
- String
-
Eg: “27.470677”.
6 7 8 |
# File 'lib/translink/page/trip.rb', line 6 def stop_lat @stop_lat end |
#stop_lon ⇒ Object
- String
-
Eg: “153.024747”.
7 8 9 |
# File 'lib/translink/page/trip.rb', line 7 def stop_lon @stop_lon end |
#stop_name ⇒ Object
- 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.
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.
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 |