Class: UWAPI::API

Inherits:
Object
  • Object
show all
Includes:
Course, Event, ExamInfo, Experimental, FacultyInfo, FoodServices, Geolocation, Other, Professor, Schedule, Weather, WirelessData
Defined in:
lib/uwapi.rb

Instance Method Summary collapse

Methods included from Abstraction

included

Methods included from Abstraction::ClassMethods

#call_with_q, #call_without_q

Constructor Details

#initialize(args) ⇒ API

Returns a new instance of API.

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
# File 'lib/uwapi.rb', line 51

def initialize(args)
  if args.include?(:api_key)
    @api_key = args[:api_key]
  else
    raise ArgumentError, ':api_key is required. See http://api.uwaterloo.ca/'
  end
  @api_format = args[:api_format] if args.include?(:api_format)
  raise ArgumentError, ':api_format must be one of [json, xml]' unless ['json', 'xml'].include?(api_format)
end

Instance Method Details

#api_formatObject



61
62
63
# File 'lib/uwapi.rb', line 61

def api_format
  @api_format ||= 'json'
end

#api_keyObject



69
70
71
# File 'lib/uwapi.rb', line 69

def api_key
  @api_key
end

#api_urlObject



65
66
67
# File 'lib/uwapi.rb', line 65

def api_url
  'http://api.uwaterloo.ca/public/v1/'
end