Sha256: 42b680aae11b13cd027e3793dfa31b4c13542c433ce815b4f011c73d3f5d7b2b
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
class Section < PCR attr_accessor :aliases, :course, :group, :id, :instructors, :meetingtimes, :name, :path, :reviews, :sectionnum, :retrieved, :valid, :version def initialize(path, api_endpt, token) @path = path @api_endpt = api_endpt @token = token # Hit api api_url = makeURL(self.path) json = JSON.parse(open(api_url).read) # Get reviews # Usually one, but may be > 1 @reviews = [] reviews_url = makeURL(json['result']['reviews']['path']) reviews_json = JSON.parse(open(reviews_url).read) reviews_json['result']['values'].each do |review| @reviews << Review.new(review) end # Assign attrs attrs = %w(aliases course group id instructors meetingtimes name sectionnum retrieved valid version) attrs.each do |attr| if json['result'][attr] self.instance_variable_set("@#{attr}", json['result'][attr]) else self.instance_variable_set("@#{attr}", json[attr]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pcr-ruby-0.5 | lib/classes/section.rb |