Class: Prawn::Document::Grid
- Inherits:
-
Object
- Object
- Prawn::Document::Grid
- Defined in:
- lib/prawn/grid.rb
Overview
A Grid represents the entire grid system of a Page and calculates the column width and row height of the base box.
Experimental API collapse
-
#column_gutter ⇒ Number
readonly
Column gutter size.
-
#columns ⇒ Integer
readonly
Number of columns in the grid.
-
#gutter ⇒ Number
readonly
Gutter size.
-
#row_gutter ⇒ Number
readonly
Row gutter size.
-
#rows ⇒ Integer
readonly
Number of rows in the grid.
Experimental API collapse
-
#column_width ⇒ Float
Calculates the base width of boxes.
-
#initialize(pdf, options = {}) ⇒ Grid
constructor
A new instance of Grid.
-
#row_height ⇒ Float
Calculates the base height of boxes.
-
#show_all(color = 'CCCCCC') ⇒ void
Diagnostic tool to show all of the grid boxes.
Constructor Details
#initialize(pdf, options = {}) ⇒ Grid
Returns a new instance of Grid.
Source Code
lib/prawn/grid.rb, line 104
104 | def initialize(pdf, options = {}) |
105 | valid_options = %i[columns rows gutter row_gutter column_gutter] |
106 | Prawn.verify_options(valid_options, options) |
107 | |
108 | @pdf = pdf |
109 | @columns = options[:columns] |
110 | @rows = options[:rows] |
111 | apply_gutter(options) |
112 | end
|
Instance Attribute Details
#column_gutter ⇒ Number (readonly)
Column gutter size.
Source Code
lib/prawn/grid.rb, line 94
94 | def column_gutter |
95 | @column_gutter
|
96 | end
|
#columns ⇒ Integer (readonly)
Number of columns in the grid.
Source Code
lib/prawn/grid.rb, line 78
78 | def columns |
79 | @columns
|
80 | end
|
#gutter ⇒ Number (readonly)
Gutter size.
Source Code
lib/prawn/grid.rb, line 86
86 | def gutter |
87 | @gutter
|
88 | end
|
#row_gutter ⇒ Number (readonly)
Row gutter size.
Source Code
lib/prawn/grid.rb, line 90
90 | def row_gutter |
91 | @row_gutter
|
92 | end
|
#rows ⇒ Integer (readonly)
Number of rows in the grid.
Source Code
lib/prawn/grid.rb, line 82
82 | def rows |
83 | @rows
|
84 | end
|
Instance Method Details
#column_width ⇒ Float
Calculates the base width of boxes.
Source Code
lib/prawn/grid.rb, line 117
117 | def column_width |
118 | @column_width ||= subdivide(pdf.bounds.width, columns, column_gutter) |
119 | end
|
#row_height ⇒ Float
Calculates the base height of boxes.
Source Code
lib/prawn/grid.rb, line 124
124 | def row_height |
125 | @row_height ||= subdivide(pdf.bounds.height, rows, row_gutter) |
126 | end
|
#show_all(color = 'CCCCCC') ⇒ void
This method returns an undefined value.
Diagnostic tool to show all of the grid boxes.
Source Code
lib/prawn/grid.rb, line 132
132 | def show_all(color = 'CCCCCC') |
133 | rows.times do |row| |
134 | columns.times do |column| |
135 | pdf.grid(row, column).show(color) |
136 | end
|
137 | end
|
138 | end
|