Class: SMTUC::Stop
- Inherits:
-
Object
- Object
- SMTUC::Stop
- Defined in:
- lib/smtuc/stop.rb
Constant Summary collapse
- API_URL =
This is a bit hacky because the only way to grab all stops is to do a lat/lon search and expand the range as high as it will go. In theory, this will return every stop in the system.
"#{BASE_API_URL}/Stops".freeze
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lon ⇒ Object
Returns the value of attribute lon.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.all ⇒ Object
Returns a list of all known stops.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Stop
constructor
A new instance of Stop.
Constructor Details
#initialize(attributes) ⇒ Stop
Returns a new instance of Stop.
10 11 12 13 14 15 |
# File 'lib/smtuc/stop.rb', line 10 def initialize(attributes) @id = attributes['Code'].gsub('SMTUC_', '') @name = attributes['Name'].strip @lat = attributes['CoordX'] @lon = attributes['CoordY'] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/smtuc/stop.rb', line 3 def id @id end |
#lat ⇒ Object
Returns the value of attribute lat.
3 4 5 |
# File 'lib/smtuc/stop.rb', line 3 def lat @lat end |
#lon ⇒ Object
Returns the value of attribute lon.
3 4 5 |
# File 'lib/smtuc/stop.rb', line 3 def lon @lon end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/smtuc/stop.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
Returns a list of all known stops
18 19 20 21 22 |
# File 'lib/smtuc/stop.rb', line 18 def self.all response = Faraday.get(API_URL + '/GetStops?oLat=40.20343598944182&oLon=-8.417298279776674&meters=99999999999') lines = JSON.parse(response.body) lines.map { |line| new(line) } end |