Class: ReportBuilder::Table::PdfBuilder
- Inherits:
-
ElementBuilder
- Object
- ElementBuilder
- ReportBuilder::Table::PdfBuilder
- Defined in:
- lib/reportbuilder/table/pdfbuilder.rb
Overview
Text Builder for ReportBuilder::Table objects.
Uses Aaron Tinio’s text-table gem
Instance Method Summary collapse
- #generate ⇒ Object
-
#parse_row(row) ⇒ Object
Parse a row.
Methods inherited from ElementBuilder
Constructor Details
This class inherits a constructor from ReportBuilder::ElementBuilder
Instance Method Details
#generate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/reportbuilder/table/pdfbuilder.rb', line 10 def generate() t=@element @pdf=@builder.pdf @rowspans=[] if !t.nil? and t.name!="" @pdf.pad_top 10 do @pdf.text t.name, {:size=>12, :align=>:center} end end return if t.header.size+t.rows.size==0 has_header=t.header.size>0 @pdf.pad(10) do if has_header =t..merge({:headers=>t.header, :align_headers=>:center}) @pdf.table(t.rows.map{|row| parse_row(row)}, ) do row(0).style(:font_style => :bold, :background_color => 'cccccc') end else @pdf.table(t.rows.map{|row| parse_row(row)}, t.) end end end |
#parse_row(row) ⇒ Object
Parse a row
33 34 35 36 37 38 39 |
# File 'lib/reportbuilder/table/pdfbuilder.rb', line 33 def parse_row(row) if row==:hr [] else row end end |