Class: Poly::Course

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#acronymObject

Returns the value of attribute acronym.



7
8
9
# File 'lib/polyhoraire/course.rb', line 7

def acronym
  @acronym
end

#creditNbrObject

Returns the value of attribute creditNbr.



7
8
9
# File 'lib/polyhoraire/course.rb', line 7

def creditNbr
  @creditNbr
end

#groupObject

Returns the value of attribute group.



7
8
9
# File 'lib/polyhoraire/course.rb', line 7

def group
  @group
end

#labGroupObject

Returns the value of attribute labGroup.



7
8
9
# File 'lib/polyhoraire/course.rb', line 7

def labGroup
  @labGroup
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/polyhoraire/course.rb', line 7

def name
  @name
end

#periodsObject (readonly)

Returns the value of attribute periods.



7
8
9
# File 'lib/polyhoraire/course.rb', line 7

def periods
  @periods
end

#professorObject

Returns the value of attribute professor.



7
8
9
# File 'lib/polyhoraire/course.rb', line 7

def professor
  @professor
end

Class Method Details

.from_nokogiri(doc) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/polyhoraire/course.rb', line 10

def self.from_nokogiri(doc)
  courses = Array.new
  
  nodeSet = doc.xpath("//cour")
  nodeSet.each do |node|
    course = self.new
    
    course.acronym     = node.attribute("sigle").text
    course.name        = node.xpath("nom").text
    course.professor   = node.xpath("prof").text
    course.group       = node.xpath("groupeTheorie").text
    course.labGroup    = node.xpath("groupeLaboratoire").text
    course.creditNbr   = node.xpath("nombreCredits").text
    
    course.addPeriods(doc)
    
    courses.push(course)
  end
  return courses
end

Instance Method Details

#addPeriods(xml) ⇒ Object



31
32
33
# File 'lib/polyhoraire/course.rb', line 31

def addPeriods (xml)
  @periods = Poly::Period.from_nokogiri(xml,@acronym) 
end

#descriptionObject



35
36
37
38
39
40
# File 'lib/polyhoraire/course.rb', line 35

def description
  name + '\n' + 
  '\t\t - Professeur   : ' + professor + '\n' + 
  '\t\t - Groupe cours : ' + group + '\n' + 
  '\t\t - Groupe lab   : ' + labGroup
end