Class: Gares::Base

Inherits:
Hashie::Dash
  • Object
show all
Defined in:
lib/gares/base.rb

Overview

Represents a station on gares-sncf.com

Direct Known Subclasses

Station

Constant Summary collapse

OPEN_DATA_SNCF =
"https://ressources.data.sncf.com/api/records/1.0/search?dataset=referentiel-gares-voyageurs&q=%s"
GARES_SNCF =
"http://www.gares-sncf.com/fr/train-times/%s/%s/gl"

Instance Method Summary collapse

Instance Method Details

#arrivals(refresh = false) ⇒ Array<Train> Also known as: arriving_trains

List of the next arriving trains in this station.

Parameters:

  • refresh (Boolean) (defaults to: false)

    whether to fetch fresh data from gares-sncf.com or not.

Returns:



79
80
81
82
83
# File 'lib/gares/base.rb', line 79

def arrivals(refresh = false)
  if tvs
    trains(:arrival, refresh)
  end
end

#departures(refresh = false) ⇒ Array<Train> Also known as: departing_trains

List of the next departing trains from this station.

Parameters:

  • refresh (Boolean) (defaults to: false)

    whether to fetch fresh data from gares-sncf.com or not.

Returns:



69
70
71
72
73
# File 'lib/gares/base.rb', line 69

def departures(refresh = false)
  if tvs
    trains(:departure, refresh)
  end
end

#has_borne?Boolean

Whether this station has a “borne” (yellow self-service ticket machine)

Returns:

  • (Boolean)


44
45
46
# File 'lib/gares/base.rb', line 44

def has_borne?
  has_bls == "t"
end

#latObject

Deprecated.


55
56
57
58
# File 'lib/gares/base.rb', line 55

def lat
  warn "[DEPRECATION] favor the 'latitude' method instead of 'lat'."
  latitude
end

#longObject

Deprecated.


61
62
63
64
# File 'lib/gares/base.rb', line 61

def long
  warn "[DEPRECATION] favor the 'longitude' method instead of 'long'."
  longitude
end

#slugObject

Deprecated.


49
50
51
52
# File 'lib/gares/base.rb', line 49

def slug
  warn "[DEPRECATION] favor the 'sncf_id' method instead of 'slug'."
  sncf_id.downcase
end