class Prawn::Document::Grid
A Grid
represents the entire grid system of a Page and calculates the column width and row height of the base box.
@group Experimental API
Attributes
Public Instance Methods
Source
# File lib/prawn/grid.rb, line 71 def column_width @column_width ||= subdivide(pdf.bounds.width, columns, column_gutter) end
Calculates the base width of boxes.
Source
# File lib/prawn/grid.rb, line 76 def row_height @row_height ||= subdivide(pdf.bounds.height, rows, row_gutter) end
Calculates the base height of boxes.
Source
# File lib/prawn/grid.rb, line 81 def show_all(color = 'CCCCCC') rows.times do |row| columns.times do |column| pdf.grid(row, column).show(color) end end end
Diagnostic tool to show all of the grids. Defaults to gray.
Private Instance Methods
Source
# File lib/prawn/grid.rb, line 95 def apply_gutter(options) if options.key?(:gutter) @gutter = options[:gutter].to_f @row_gutter = @gutter @column_gutter = @gutter else @row_gutter = options[:row_gutter].to_f @column_gutter = options[:column_gutter].to_f @gutter = 0 end end
Source
# File lib/prawn/grid.rb, line 91 def subdivide(total, num, gutter) (total.to_f - (gutter * (num - 1).to_f)) / num.to_f end