Class: Mo2tex::School
- Inherits:
-
Object
- Object
- Mo2tex::School
- Includes:
- CourseHelper
- Defined in:
- lib/mo2tex/school.rb
Instance Attribute Summary collapse
-
#cal ⇒ Object
readonly
Returns the value of attribute cal.
-
#courses ⇒ Object
readonly
Returns the value of attribute courses.
-
#exm ⇒ Object
readonly
Returns the value of attribute exm.
Instance Method Summary collapse
- #each_course(&block) ⇒ Object
-
#generate(head, tail, &block) ⇒ Object
generate(head, tail, &block).
-
#initialize(config) ⇒ School
constructor
A new instance of School.
- #warnings(&block) ⇒ Object
Methods included from CourseHelper
Constructor Details
#initialize(config) ⇒ School
Returns a new instance of School.
11 12 13 |
# File 'lib/mo2tex/school.rb', line 11 def initialize(config) parse(config) end |
Instance Attribute Details
#cal ⇒ Object (readonly)
Returns the value of attribute cal.
9 10 11 |
# File 'lib/mo2tex/school.rb', line 9 def cal @cal end |
#courses ⇒ Object (readonly)
Returns the value of attribute courses.
9 10 11 |
# File 'lib/mo2tex/school.rb', line 9 def courses @courses end |
#exm ⇒ Object (readonly)
Returns the value of attribute exm.
9 10 11 |
# File 'lib/mo2tex/school.rb', line 9 def exm @exm end |
Instance Method Details
#each_course(&block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/mo2tex/school.rb', line 15 def each_course(&block) self.courses.each do |title, course| yield(title, course) end end |
#generate(head, tail, &block) ⇒ Object
generate(head, tail, &block)
-
head: is a proc that is called before each table
-
tail: is a proc that is called after each table
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mo2tex/school.rb', line 28 def generate(head, tail, &block) result = '' hours_done = 0 self.each_course do |title, c| studs_fc = c.students_fc ? (', \textcolor{gray}{' + c.students_fc + '}') : '' studs = c.students + studs_fc result += head.call(title, studs) result += c.generate(&block) result += tail.call(c.hours_done) hours_done += c.hours_done end return [hours_done, result] end |
#warnings(&block) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/mo2tex/school.rb', line 43 def warnings(&block) return unless block_given? self.courses.each do |c| c.warnings.each { |k, v| yield(k, v) } end end |