Class: PCR::Client
- Inherits:
-
Object
- Object
- PCR::Client
- Defined in:
- lib/pcr.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #coursehistory(course_code) ⇒ Object
- #dept(code) ⇒ Object
- #get_json(path) ⇒ Object
-
#initialize(token, api_endpt = "http://api.penncoursereview.com/v1/") ⇒ Client
constructor
A new instance of Client.
- #instructor(id) ⇒ Object
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
#token ⇒ Object (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
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
24 25 26 |
# File 'lib/pcr.rb', line 24 def instructor(id) raise NotImplementedError.new("Instructors have not yet been implemented.") end |