Class: AltaBikes::City
- Inherits:
-
Object
- Object
- AltaBikes::City
- Defined in:
- lib/alta_bikes/city.rb
Instance Attribute Summary collapse
-
#json_url ⇒ Object
Returns the value of attribute json_url.
-
#station_list ⇒ Object
Returns the value of attribute station_list.
-
#stations_root ⇒ Object
Returns the value of attribute stations_root.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(configuration = AltaBikes.configuration) ⇒ City
constructor
A new instance of City.
- #refresh_stations ⇒ Object
- #stations(id = nil) ⇒ Object
Constructor Details
#initialize(configuration = AltaBikes.configuration) ⇒ City
Returns a new instance of City.
12 13 14 15 16 17 |
# File 'lib/alta_bikes/city.rb', line 12 def initialize(configuration = AltaBikes.configuration) raise JsonURLRequired if configuration.json_url.nil? @json_url = configuration.json_url @stations_root = configuration.stations_root @station_list = [] end |
Instance Attribute Details
#json_url ⇒ Object
Returns the value of attribute json_url.
10 11 12 |
# File 'lib/alta_bikes/city.rb', line 10 def json_url @json_url end |
#station_list ⇒ Object
Returns the value of attribute station_list.
10 11 12 |
# File 'lib/alta_bikes/city.rb', line 10 def station_list @station_list end |
#stations_root ⇒ Object
Returns the value of attribute stations_root.
10 11 12 |
# File 'lib/alta_bikes/city.rb', line 10 def stations_root @stations_root end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
10 11 12 |
# File 'lib/alta_bikes/city.rb', line 10 def updated_at @updated_at end |
Instance Method Details
#refresh_stations ⇒ Object
26 27 28 29 |
# File 'lib/alta_bikes/city.rb', line 26 def refresh_stations @station_list = [] stations end |
#stations(id = nil) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/alta_bikes/city.rb', line 19 def stations(id = nil) get_stations if station_list.empty? return station_list.select { |station| station.details[:id] == id }[0] if !id.nil? station_list end |