Class: Mo2tex::Latex
- Inherits:
-
Object
- Object
- Mo2tex::Latex
- Defined in:
- lib/mo2tex/latex.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#school ⇒ Object
readonly
Returns the value of attribute school.
-
#total_hours_done ⇒ Object
readonly
Returns the value of attribute total_hours_done.
-
#trailer ⇒ Object
readonly
Returns the value of attribute trailer.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(s) ⇒ Latex
constructor
A new instance of Latex.
- #table_body ⇒ Object
Constructor Details
#initialize(s) ⇒ Latex
Returns a new instance of Latex.
13 14 15 16 17 18 19 |
# File 'lib/mo2tex/latex.rb', line 13 def initialize(s) @total_hours_done = 0 @school = s @header = read_header @trailer = read_trailer @body = read_body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
11 12 13 |
# File 'lib/mo2tex/latex.rb', line 11 def body @body end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
11 12 13 |
# File 'lib/mo2tex/latex.rb', line 11 def header @header end |
#school ⇒ Object (readonly)
Returns the value of attribute school.
11 12 13 |
# File 'lib/mo2tex/latex.rb', line 11 def school @school end |
#total_hours_done ⇒ Object (readonly)
Returns the value of attribute total_hours_done.
11 12 13 |
# File 'lib/mo2tex/latex.rb', line 11 def total_hours_done @total_hours_done end |
#trailer ⇒ Object (readonly)
Returns the value of attribute trailer.
11 12 13 |
# File 'lib/mo2tex/latex.rb', line 11 def trailer @trailer end |
Instance Method Details
#generate ⇒ Object
21 22 23 24 25 |
# File 'lib/mo2tex/latex.rb', line 21 def generate result = self.header result += self.body.result(binding) result += self.trailer end |
#table_body ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mo2tex/latex.rb', line 27 def table_body result = '' head = proc { |title, students| "\\hline\n\\multicolumn{3}{|l|}{\\bfseries #{title}}\\\\\n\\multicolumn{3}{|p{0.9\\textwidth}|}{studenti: #{students}}\\\\\n\\hline\n" } tail = proc { |sctot| "\\multicolumn{2}{l}{Totale ore corso:} & \\hfill#{sctot.round.to_i}\\\\\n & & \\\\\n" } @total_hours_done, result = self.school.generate(head, tail) do |title, nol, ev| sprintf("%s & %s--%s & Lezione n.%02d/%02d\\\\\n", ev.dtstart.strftime("%d/%m/%Y"), ev.dtstart.strftime("%H:%M"), ev.dtend.strftime("%H:%M"), ev.lnumber, ev.ltot) end @total_hours_done = @total_hours_done.round.to_i return result end |