Sha256: 26a4f343f7f9314a11ea7794793c52de0975963d3e6d5f012b0d1f01b7a50ab3

Contents?: true

Size: 479 Bytes

Versions: 3

Compression:

Stored size: 479 Bytes

Contents

require 'httparty'
require 'uwaterlooapi/version'
require 'uwaterlooapi/routes'
require 'uwaterlooapi/query'

class UWaterlooAPI
  include UWaterlooAPI::Routes

  def initialize(api_key)
    get_base_routes.each do |route|
      self.class.send :define_method, route do
        UWaterlooAPI::Query.new "/#{route}", "/#{route}", api_key
      end
    end
  end

private

  def get_base_routes
    @base_routes ||= @@routes.map { |r| r.split('/')[1] }.uniq.map(&:to_sym)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uwaterlooapi-0.1.1 lib/uwaterlooapi.rb
uwaterlooapi-0.1.0 lib/uwaterlooapi.rb
uwaterlooapi-0.0.4 lib/uwaterlooapi.rb