Class: Rubyword::Element::Table
- Defined in:
- lib/rubyword/element/table.rb
Instance Attribute Summary collapse
-
#trs ⇒ Object
Returns the value of attribute trs.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(rubyword, section = nil, style) ⇒ Table
constructor
A new instance of Table.
- #tr(style = nil, &block) ⇒ Object
- #write(section = nil, xml = nil) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(rubyword, section = nil, style) ⇒ Table
Returns a new instance of Table.
6 7 8 9 10 |
# File 'lib/rubyword/element/table.rb', line 6 def initialize(rubyword, section=nil, style) super(rubyword, section) @style = style @trs ||= [] end |
Instance Attribute Details
#trs ⇒ Object
Returns the value of attribute trs.
5 6 7 |
# File 'lib/rubyword/element/table.rb', line 5 def trs @trs end |
Instance Method Details
#tr(style = nil, &block) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rubyword/element/table.rb', line 12 def tr(style=nil, &block) return unless block_given? tr = Tr.new tr.instance_eval(&block) @trs << tr end |
#write(section = nil, xml = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubyword/element/table.rb', line 19 def write(section=nil, xml=nil) @xml = xml @xml.send('w:tbl') { @xml.send('w:tblGrid') { @xml.send('w:gridCol', 'w:w' => '1750', 'w:type' => 'dxa') @xml.send('w:gridCol', 'w:w' => '1750', 'w:type' => 'dxa') @xml.send('w:gridCol', 'w:w' => '1750', 'w:type' => 'dxa') } @trs.each do |tr| @xml.send('w:tr') { @xml.send('w:trPr') tr.texts.each do |text| @xml.send('w:tc') { @xml.send('w:tcPr') { @xml.send('w:tcW', 'w:w'=>'1750', 'w:type' => 'dxa') } @xml.send('w:p') { Writer::Style::Paragraph.new(@section, @xml, @rubyword).write(text[:style]) @xml.send('w:r') do Writer::Style::Word.new(@section, @xml, @rubyword).write(text[:style]) @xml.send('w:t', {'xml:space' => 'preserve'}, text[:text]) end } } end } end } end |