A Grid represents the entire grid system of a Page and calculates the column width and row height of the base box.
Calculates the base width of boxes.
# File lib/prawn/layout/grid.rb, line 49 def column_width @column_width ||= subdivide(pdf.bounds.width, columns, column_gutter) end
Calculates the base height of boxes.
# File lib/prawn/layout/grid.rb, line 54 def row_height @row_height ||= subdivide(pdf.bounds.height, rows, row_gutter) end
Diagnostic tool to show all of the grids. Defaults to gray.
# File lib/prawn/layout/grid.rb, line 59 def show_all(color = "CCCCCC") self.rows.times do |i| self.columns.times do |j| pdf.grid(i,j).show(color) end end end
# File lib/prawn/layout/grid.rb, line 73 def set_gutter(options) if options.has_key?(:gutter) @gutter = options[:gutter].to_f @row_gutter, @column_gutter = @gutter, @gutter else @row_gutter = options[:row_gutter].to_f @column_gutter = options[:column_gutter].to_f @gutter = 0 end end
# File lib/prawn/layout/grid.rb, line 69 def subdivide(total, num, gutter) (total.to_f - (gutter * (num - 1).to_f)) / num.to_f end