Class: Section
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#course ⇒ Object
Returns the value of attribute course.
-
#group ⇒ Object
Returns the value of attribute group.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instructors ⇒ Object
Returns the value of attribute instructors.
-
#meetingtimes ⇒ Object
Returns the value of attribute meetingtimes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#retrieved ⇒ Object
Returns the value of attribute retrieved.
-
#reviews ⇒ Object
Returns the value of attribute reviews.
-
#sectionnum ⇒ Object
Returns the value of attribute sectionnum.
-
#valid ⇒ Object
Returns the value of attribute valid.
-
#version ⇒ Object
Returns the value of attribute version.
Attributes inherited from PCR
Instance Method Summary collapse
-
#initialize(path, api_endpt, token) ⇒ Section
constructor
A new instance of Section.
Methods inherited from PCR
Constructor Details
#initialize(path, api_endpt, token) ⇒ Section
Returns a new instance of Section.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/classes/section.rb', line 6 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 |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def aliases @aliases end |
#course ⇒ Object
Returns the value of attribute course.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def course @course end |
#group ⇒ Object
Returns the value of attribute group.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def group @group end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def id @id end |
#instructors ⇒ Object
Returns the value of attribute instructors.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def instructors @instructors end |
#meetingtimes ⇒ Object
Returns the value of attribute meetingtimes.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def meetingtimes @meetingtimes end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def path @path end |
#retrieved ⇒ Object
Returns the value of attribute retrieved.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def retrieved @retrieved end |
#reviews ⇒ Object
Returns the value of attribute reviews.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def reviews @reviews end |
#sectionnum ⇒ Object
Returns the value of attribute sectionnum.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def sectionnum @sectionnum end |
#valid ⇒ Object
Returns the value of attribute valid.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def valid @valid end |
#version ⇒ Object
Returns the value of attribute version.
2 3 4 |
# File 'lib/classes/section.rb', line 2 def version @version end |