Class: Prawn::Markup::Builders::TableBuilder

Inherits:
NestableBuilder show all
Defined in:
lib/prawn/markup/builders/table_builder.rb

Constant Summary collapse

FAILOVER_STRATEGIES =
%i[equal_widths subtable_placeholders].freeze
DEFAULT_CELL_PADDING =
5
MIN_COL_WIDTH =
1.cm

Constants inherited from NestableBuilder

NestableBuilder::TEXT_STYLE_OPTIONS

Instance Method Summary collapse

Constructor Details

#initialize(pdf, cells, total_width, options = {}) ⇒ TableBuilder

Returns a new instance of TableBuilder.



11
12
13
14
15
# File 'lib/prawn/markup/builders/table_builder.rb', line 11

def initialize(pdf, cells, total_width, options = {})
  super(pdf, total_width, options)
  @cells = cells
  @column_widths = []
end

Instance Method Details

#drawObject



22
23
24
25
26
27
28
29
30
# File 'lib/prawn/markup/builders/table_builder.rb', line 22

def draw
  make.draw
rescue Prawn::Errors::CannotFit => e
  if failover_on_error
    draw
  else
    raise e
  end
end

#makeObject



17
18
19
20
# File 'lib/prawn/markup/builders/table_builder.rb', line 17

def make
  compute_column_widths
  pdf.make_table(convert_cells, prawn_table_options)
end