Sha256: 099d3ac86fd6aecc548ac0ee1ae47d2a18e6370829017462f21841099aaf27d8
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'httparty' require 'pry' module RubyRides class Client include HTTParty base_uri "http://hubwaydatachallenge.org/api/v1" attr_accessor :options 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 def client_id @options[:client_id] end def client_api_key @options[:client_api_key] end def station_data JSON.parse self.class.get("/station/?format=json&username=#{@options[:client_id]}&api_key=#{@options[:client_api_key]}").body end 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby_rides-0.0.4 | lib/ruby_rides/client.rb |