Class: Docxer::Word::Contents::Table
- Inherits:
-
Object
- Object
- Docxer::Word::Contents::Table
- Defined in:
- lib/docxer/word/contents/table.rb
Defined Under Namespace
Classes: TableRow
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Table
constructor
A new instance of Table.
- #render(xml) ⇒ Object
- #tr(options = {}, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Table
Returns a new instance of Table.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/docxer/word/contents/table.rb', line 8 def initialize(={}) @options = @rows = [] if block_given? yield self else end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/docxer/word/contents/table.rb', line 7 def @options end |
#rows ⇒ Object
Returns the value of attribute rows.
7 8 9 |
# File 'lib/docxer/word/contents/table.rb', line 7 def rows @rows end |
Instance Method Details
#render(xml) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/docxer/word/contents/table.rb', line 26 def render(xml) xml['w'].tbl do xml['w'].tblPr do xml['w'].tblStyle( 'w:val' => [:style] ) if [:style] xml['w'].tblW( 'w:w' => [:width], 'w:type' => "auto" ) if [:width] xml['w'].tblLook( 'w:val' => "04A0", 'w:firstRow' => 1, 'w:lastRow' => 0, 'w:firstColumn' => 1, 'w:lastColumn' => 0, 'w:noHBand' => 0, 'w:noVBand' => 1 ) if @options[:borders] xml['w'].tblBorders do @options[:borders].each do |k, v| if v.nil? xml['w'].send(k, 'w:val' => "none", 'w:sz' => "0", 'w:space' => "0", 'w:color' => "auto" ) else xml['w'].send(k, 'w:val' => "none", 'w:sz' => v, 'w:space' => "0", 'w:color' => "auto" ) end end end end end xml['w'].tblGrid do if [:columns_width] [:columns_width].each do |width| xml['w'].gridCol( 'w:w' => width.to_i * 14.92 ) end end end @rows.each do |row| row.render(xml) end end end |