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
Column gutter size. @return [Number]
Number of columns in the grid. @return [Integer]
Gutter size. @return [Number]
@private @return [Prawn::Document]
Row gutter size. @return [Number]
Number of rows in the grid. @return [Integer]
Public Class Methods
Source
# File lib/prawn/grid.rb, line 104 def initialize(pdf, options = {}) valid_options = %i[columns rows gutter row_gutter column_gutter] Prawn.verify_options(valid_options, options) @pdf = pdf @columns = options[:columns] @rows = options[:rows] apply_gutter(options) end
@param pdf [Prawn::Document] @param options [Hash{Symbol => any}] @option options :columns [Integer] Number of columns in the grid. @option options :rows [Integer] Number of rows in the grid. @option options :gutter [Number] Gutter size. ‘:row_gutter` and
`:column_gutter` are ignored if specified.
@option options :row_gutter [Number] Row gutter size. @option options :column_gutter [Number] Column gutter size.
Public Instance Methods
Source
# File lib/prawn/grid.rb, line 117 def column_width @column_width ||= subdivide(pdf.bounds.width, columns, column_gutter) end
Calculates the base width of boxes.
@return [Float]
Source
# File lib/prawn/grid.rb, line 124 def row_height @row_height ||= subdivide(pdf.bounds.height, rows, row_gutter) end
Calculates the base height of boxes.
@return [Float]
Source
# File lib/prawn/grid.rb, line 132 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 grid boxes.
@param color [Color] @return [void]