module DublinBikes::Client::Stations

Public Instance Methods

stations() click to toggle source
# File lib/dublin_bikes/client/stations.rb, line 4
def stations
  @_stations ||= begin
    response = get('carto')
    payload = response.body
    marker_list = DublinBikes::ApiMarkerList.parse(payload, single: true)
    marker_list.markers.map do |marker|
      DublinBikes::Station.new(marker)
    end
  end
end
stations_closest_to(lat, lng) click to toggle source
# File lib/dublin_bikes/client/stations.rb, line 15
def stations_closest_to(lat, lng)
  stations.sort_by { |station| station.distance_to(lat, lng) }
end