Class: Docxi::Word::Contents::Table::TableRow

Inherits:
Object
  • Object
show all
Defined in:
lib/docxi/word/contents/table.rb

Defined Under Namespace

Classes: TableCell

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TableRow

Returns a new instance of TableRow.



71
72
73
74
75
76
77
78
79
80
# File 'lib/docxi/word/contents/table.rb', line 71

def initialize(options={})
  @options = options
  @cells = []

  if block_given?
    yield self
  else

  end
end

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



70
71
72
# File 'lib/docxi/word/contents/table.rb', line 70

def cells
  @cells
end

#optionsObject

Returns the value of attribute options.



70
71
72
# File 'lib/docxi/word/contents/table.rb', line 70

def options
  @options
end

Instance Method Details

#render(xml) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/docxi/word/contents/table.rb', line 93

def render(xml)
  xml['w'].tr do
    if options[:height].present?
      xml['w'].trPr do
        xml['w'].trHeight('w:val' => options[:height], 'w:hRule' => 'atLeast')
        xml['w'].cantSplit('w:val' => 'false')
      end
    end
    @cells.each do |cell|
      cell.render(xml)
    end
  end
end

#tc(options = {}, &block) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/docxi/word/contents/table.rb', line 82

def tc(options={}, &block)
  if @options[:columns_width]
    width = @options[:columns_width][@cells.size]
    options[:width] ||= width if width
  end
  options = @options.merge(options)
  cell = TableCell.new(options, &block)
  @cells << cell
  cell
end