Class: Prawn::Document::ColumnBox
- Inherits:
-
BoundingBox
- Object
- BoundingBox
- Prawn::Document::ColumnBox
- Defined in:
- lib/prawn/document/column_box.rb
Overview
Implements the necessary functionality to allow #column_box to work.
Experimental API collapse
-
#bare_column_width ⇒ Number
The column width, not the width of the whole box, before left and/or right padding.
-
#initialize(document, parent, point, options = {}) ⇒ ColumnBox
constructor
A new instance of ColumnBox.
-
#left ⇒ Number
Relative position of the left edge of the current column.
-
#left_side ⇒ Number
x coordinate of the left edge of the current column.
-
#move_past_bottom ⇒ void
Moves to the next column or starts a new page if currently positioned at the rightmost column.
-
#right ⇒ Number
Relative position of the right edge of the current column.
-
#right_side ⇒ Number
x coordinate of the right edge of the current column.
-
#width ⇒ Number
The column width after padding.
-
#width_of_column ⇒ Number
Column width including the spacer.
Constructor Details
#initialize(document, parent, point, options = {}) ⇒ ColumnBox
Returns a new instance of ColumnBox.
Source Code
68 | def initialize(document, parent, point, options = {}) |
69 | super
|
70 | @columns = options[:columns] || 3 |
71 | @spacer = options[:spacer] || @document.font_size |
72 | @current_column = 0 |
73 | @reflow_margins = options[:reflow_margins] |
74 | end
|
Instance Method Details
#bare_column_width ⇒ Number
The column width, not the width of the whole box, before left and/or right padding.
Source Code
80 | def bare_column_width |
81 | (@width - (@spacer * (@columns - 1))) / @columns |
82 | end
|
#left ⇒ Number
Relative position of the left edge of the current column.
Source Code
109 | def left |
110 | width_of_column * @current_column |
111 | end
|
#left_side ⇒ Number
x coordinate of the left edge of the current column.
Source Code
102 | def left_side |
103 | absolute_left + (width_of_column * @current_column) |
104 | end
|
#move_past_bottom ⇒ void
This method returns an undefined value.
Moves to the next column or starts a new page if currently positioned at the rightmost column.
Source Code
132 | def move_past_bottom |
133 | @current_column = (@current_column + 1) % @columns |
134 | @document.y = @y |
135 | if @current_column.zero? |
136 | if @reflow_margins |
137 | @y = @parent.absolute_top |
138 | end
|
139 | @document.start_new_page |
140 | end
|
141 | end
|
#right ⇒ Number
Relative position of the right edge of the current column.
Source Code
124 | def right |
125 | left + width |
126 | end
|
#right_side ⇒ Number
x coordinate of the right edge of the current column.
Source Code
116 | def right_side |
117 | columns_from_right = @columns - (1 + @current_column) |
118 | absolute_right - (width_of_column * columns_from_right) |
119 | end
|
#width ⇒ Number
The column width after padding. Used to calculate how long a line of text can be.
Source Code
88 | def width |
89 | bare_column_width - (@total_left_padding + @total_right_padding) |
90 | end
|
#width_of_column ⇒ Number
Column width including the spacer.
Source Code
95 | def width_of_column |
96 | bare_column_width + @spacer |
97 | end
|