Class: Gares::TrainStop
- Inherits:
-
Object
- Object
- Gares::TrainStop
- Defined in:
- lib/gares/train_stop.rb
Overview
Represents a stop for a train from www.sncf.com/fr/horaires-info-trafic/train
Instance Attribute Summary collapse
-
#arrival_date ⇒ Object
Returns the value of attribute arrival_date.
-
#departure_date ⇒ Object
Returns the value of attribute departure_date.
-
#formatted_info ⇒ String
A formatted detailed information in HTML.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#real_arrival_date ⇒ Object
Returns the value of attribute real_arrival_date.
-
#real_departure_date ⇒ Object
Returns the value of attribute real_departure_date.
-
#station ⇒ Object
Returns the value of attribute station.
Instance Method Summary collapse
- #delayed? ⇒ Boolean
-
#initialize(nokogiri_node, date) ⇒ TrainStop
constructor
Given the HTML node from sncf.com/fr/horaires-info-trafic/train containing the stop and the
datefor this train stop. -
#minutes_of_delay ⇒ Integer
The amount of minutes of delay at this stop.
Constructor Details
#initialize(nokogiri_node, date) ⇒ TrainStop
Given the HTML node from sncf.com/fr/horaires-info-trafic/train containing the stop and the date for this train stop. The object gathers all useful information about the stop made by the train.
33 34 35 36 37 38 |
# File 'lib/gares/train_stop.rb', line 33 def initialize(nokogiri_node, date) initialize_dates(nokogiri_node, date) initialize_station(nokogiri_node) @platform = nokogiri_node.at('td.track').inner_html.strip @formatted_info = nokogiri_node.at('td.info').inner_html.strip end |
Instance Attribute Details
#arrival_date ⇒ Object
Returns the value of attribute arrival_date.
|
|
# File 'lib/gares/train_stop.rb', line 12
|
#departure_date ⇒ Object
Returns the value of attribute departure_date.
|
|
# File 'lib/gares/train_stop.rb', line 6
|
#formatted_info ⇒ String
27 28 |
# File 'lib/gares/train_stop.rb', line 27 attr_accessor :departure_date, :real_departure_date, :arrival_date, :real_arrival_date, :station, :platform, :formatted_info |
#platform ⇒ Object
Returns the value of attribute platform.
|
|
# File 'lib/gares/train_stop.rb', line 21
|
#real_arrival_date ⇒ Object
Returns the value of attribute real_arrival_date.
|
|
# File 'lib/gares/train_stop.rb', line 15
|
#real_departure_date ⇒ Object
Returns the value of attribute real_departure_date.
|
|
# File 'lib/gares/train_stop.rb', line 9
|
#station ⇒ Object
Returns the value of attribute station.
|
|
# File 'lib/gares/train_stop.rb', line 18
|
Instance Method Details
#delayed? ⇒ Boolean
40 41 42 |
# File 'lib/gares/train_stop.rb', line 40 def delayed? minutes_of_delay > 0 end |
#minutes_of_delay ⇒ Integer
45 46 47 48 49 50 51 |
# File 'lib/gares/train_stop.rb', line 45 def minutes_of_delay if @real_departure_date (@real_departure_date - @departure_date) / 60 else 0 end end |