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 Document#column_box to work.
Experimental API collapse
-
#add_left_padding(left_padding) ⇒ Object
Override the padding functions so as not to split the padding amount between all columns on the page.
- #add_right_padding(right_padding) ⇒ Object
-
#bare_column_width ⇒ Object
The column width, not the width of the whole box, before left and/or right padding.
-
#initialize(document, parent, point, options = {}) ⇒ ColumnBox
constructor
:nodoc:.
-
#left ⇒ Object
Relative position of the left edge of the current column.
-
#left_side ⇒ Object
x coordinate of the left edge of the current column.
-
#move_past_bottom ⇒ Object
Moves to the next column or starts a new page if currently positioned at the rightmost column.
-
#right ⇒ Object
Relative position of the right edge of the current column.
-
#right_side ⇒ Object
x co-orordinate of the right edge of the current column.
- #subtract_left_padding(left_padding) ⇒ Object
- #subtract_right_padding(right_padding) ⇒ Object
-
#width ⇒ Object
The column width after padding.
-
#width_of_column ⇒ Object
Column width including the spacer.
Methods inherited from BoundingBox
#absolute_bottom, #absolute_bottom_left, #absolute_bottom_right, #absolute_left, #absolute_right, #absolute_top, #absolute_top_left, #absolute_top_right, #bottom, #bottom_left, #bottom_right, #height, #reference_bounds, #stretchy?, #top, #top_left, #top_right
Constructor Details
#initialize(document, parent, point, options = {}) ⇒ ColumnBox
:nodoc:
55 56 57 58 59 60 61 |
# File 'lib/prawn/document/column_box.rb', line 55 def initialize(document, parent, point, = {}) #:nodoc: super @columns = [:columns] || 3 @spacer = [:spacer] || @document.font_size @current_column = 0 @reflow_margins = [:reflow_margins] end |
Instance Method Details
#add_left_padding(left_padding) ⇒ Object
Override the padding functions so as not to split the padding amount between all columns on the page.
123 124 125 126 |
# File 'lib/prawn/document/column_box.rb', line 123 def add_left_padding(left_padding) @total_left_padding += left_padding @x += left_padding end |
#add_right_padding(right_padding) ⇒ Object
133 134 135 |
# File 'lib/prawn/document/column_box.rb', line 133 def add_right_padding(right_padding) @total_right_padding += right_padding end |
#bare_column_width ⇒ Object
The column width, not the width of the whole box, before left and/or right padding
65 66 67 |
# File 'lib/prawn/document/column_box.rb', line 65 def (@width - @spacer * (@columns - 1)) / @columns end |
#left ⇒ Object
Relative position of the left edge of the current column
90 91 92 |
# File 'lib/prawn/document/column_box.rb', line 90 def left width_of_column * @current_column end |
#left_side ⇒ Object
x coordinate of the left edge of the current column
84 85 86 |
# File 'lib/prawn/document/column_box.rb', line 84 def left_side absolute_left + (width_of_column * @current_column) end |
#move_past_bottom ⇒ Object
Moves to the next column or starts a new page if currently positioned at the rightmost column.
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/prawn/document/column_box.rb', line 109 def move_past_bottom @current_column = (@current_column + 1) % @columns @document.y = @y if @current_column.zero? if @reflow_margins @y = @parent.absolute_top end @document.start_new_page end end |
#right ⇒ Object
Relative position of the right edge of the current column.
103 104 105 |
# File 'lib/prawn/document/column_box.rb', line 103 def right left + width end |
#right_side ⇒ Object
x co-orordinate of the right edge of the current column
96 97 98 99 |
# File 'lib/prawn/document/column_box.rb', line 96 def right_side columns_from_right = @columns - (1 + @current_column) absolute_right - (width_of_column * columns_from_right) end |
#subtract_left_padding(left_padding) ⇒ Object
128 129 130 131 |
# File 'lib/prawn/document/column_box.rb', line 128 def subtract_left_padding(left_padding) @total_left_padding -= left_padding @x -= left_padding end |
#subtract_right_padding(right_padding) ⇒ Object
137 138 139 |
# File 'lib/prawn/document/column_box.rb', line 137 def subtract_right_padding(right_padding) @total_right_padding -= right_padding end |
#width ⇒ Object
The column width after padding. Used to calculate how long a line of text can be.
72 73 74 |
# File 'lib/prawn/document/column_box.rb', line 72 def width - (@total_left_padding + @total_right_padding) end |
#width_of_column ⇒ Object
Column width including the spacer.
78 79 80 |
# File 'lib/prawn/document/column_box.rb', line 78 def width_of_column + @spacer end |