Method: Prawn::Table::Cell#width
- Defined in:
- lib/prawn/table/cell.rb
#width ⇒ Object
Returns the cell’s width in points, inclusive of padding. If the cell is the master cell of a colspan, returns the width of the entire span group.
259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/prawn/table/cell.rb', line 259 def width return width_ignoring_span if @colspan == 1 && @rowspan == 1 # We're in a span group; get the maximum width per column (including # the master cell) and sum each column. column_widths = Hash.new(0) dummy_cells.each do |cell| column_widths[cell.column] = [column_widths[cell.column], cell.width].max end column_widths[column] = [column_widths[column], width_ignoring_span].max column_widths.values.inject(0, &:+) end |