Class: Poly::Schedule

Inherits:
Object
  • Object
show all
Includes:
Poly
Defined in:
lib/polyhoraire/schedule.rb

Constant Summary

Constants included from Poly

URL, XSLDocs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Poly

#fetch, userConfDir, userConfDir=

Constructor Details

#initialize(auth, trimester) ⇒ Schedule

Trimesters : Hash of the possible trimesters => :label postParams : PostParams obtained from the connection



11
12
13
14
15
16
17
18
# File 'lib/polyhoraire/schedule.rb', line 11

def initialize(auth,trimester)
  @params = auth.postParams
  @trimesters = auth.trimesters
  
  @trimester = Poly::Trimester.fromYAML(trimester)
  
  get(trimester)
end

Instance Attribute Details

#trimesterObject (readonly)

Returns the value of attribute trimester.



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

def trimester
  @trimester
end

Instance Method Details

#coursesObject



38
39
40
41
# File 'lib/polyhoraire/schedule.rb', line 38

def courses
  doc = to_xml_doc
  Poly::Course.from_nokogiri(doc)
end

#to_xmlObject



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

def to_xml
  to_xml_doc.to_s
end

#to_xml_docObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/polyhoraire/schedule.rb', line 24

def to_xml_doc
  html = @response.body.to_s
  # Too much spaces, substring-after wont work in some case if their still have trailling character ' ' 
  html.gsub!(" ","")

  doc = Nokogiri::HTML(html) do |config|
    config.noent
  end

  xsl = Nokogiri::XSLT(File.read(Poly::XSLDocs[:poly2XML]))
  
  return xsl.transform(doc)
end