Class: PCR::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pcr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, api_endpt = "http://api.penncoursereview.com/v1/") ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/pcr.rb', line 10

def initialize(token, api_endpt = "http://api.penncoursereview.com/v1/")
  @token = token
  @api_endpt = api_endpt
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/pcr.rb', line 8

def token
  @token
end

Instance Method Details

#coursehistory(course_code) ⇒ Object



20
21
22
# File 'lib/pcr.rb', line 20

def coursehistory(course_code)
  CourseHistory.new(course_code)
end

#dept(code) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/pcr.rb', line 28

def dept(code)
  raise NotImplementedError.new("Departments have not yet been implemented.")
end

#get_json(path) ⇒ Object



15
16
17
18
# File 'lib/pcr.rb', line 15

def get_json(path)
  #TODO: Error handling for bad/no token
  JSON.parse(open("#{@api_endpt + path}?token=#{@token}").read)
end

#instructor(id) ⇒ Object

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/pcr.rb', line 24

def instructor(id)
  raise NotImplementedError.new("Instructors have not yet been implemented.")
end