class RubyRides::Client

Attributes

options[RW]

Public Class Methods

new(options={}) click to toggle source
# File lib/ruby_rides/client.rb, line 10
def initialize(options={})
        if options[:client_id].nil? || options[:client_api_key].nil?
                raise ArgumentError.new ("A client_username and client_api_key must be present in the options hash.")
        end
        @options = options
end

Public Instance Methods

client_api_key() click to toggle source
# File lib/ruby_rides/client.rb, line 21
def client_api_key
        @options[:client_api_key]
end
client_id() click to toggle source
# File lib/ruby_rides/client.rb, line 17
def client_id
        @options[:client_id]
end
station_data() click to toggle source
# File lib/ruby_rides/client.rb, line 25
def station_data
        JSON.parse self.class.get("/station/?format=json&username=#{@options[:client_id]}&api_key=#{@options[:client_api_key]}").body
end
station_geo_locations() click to toggle source
# File lib/ruby_rides/client.rb, line 29
def station_geo_locations
        json = JSON.parse self.class.get("/station/?format=json&username=#{@options[:client_id]}&api_key=#{@options[:client_api_key]}").body
        data = json['objects']
        station_coordinates = {}

        data.each do |d|
                h = Hash["#{d['name']}", d['point']['coordinates']]
                station_coordinates.merge!(h)                               
        end
        station_coordinates
end