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.
Instance Attribute Summary
Attributes inherited from BoundingBox
Instance Method Summary collapse
-
#initialize(parent, point, options = {}) ⇒ ColumnBox
constructor
:nodoc:.
-
#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_side ⇒ Object
x co-orordinate of the right edge of the current column.
-
#width ⇒ Object
The column width, not the width of the whole box.
-
#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, #anchor, #bottom, #bottom_left, #bottom_right, #height, #indent, #left, #right, #stretchy?, #top, #top_left, #top_right
Constructor Details
#initialize(parent, point, options = {}) ⇒ ColumnBox
:nodoc:
69 70 71 72 73 74 |
# File 'lib/prawn/document/column_box.rb', line 69 def initialize(parent, point, ={}) #:nodoc: super @columns = [:columns] || 3 @spacer = [:spacer] || @parent.font_size @current_column = 0 end |
Instance Method Details
#left_side ⇒ Object
x coordinate of the left edge of the current column
91 92 93 |
# File 'lib/prawn/document/column_box.rb', line 91 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.
104 105 106 107 108 109 110 |
# File 'lib/prawn/document/column_box.rb', line 104 def move_past_bottom @current_column = (@current_column + 1) % @columns @parent.y = @y if 0 == @current_column @parent.start_new_page end end |
#right_side ⇒ Object
x co-orordinate of the right edge of the current column
97 98 99 100 |
# File 'lib/prawn/document/column_box.rb', line 97 def right_side columns_from_right = @columns - (1 + @current_column) absolute_right - (width_of_column * columns_from_right) end |
#width ⇒ Object
The column width, not the width of the whole box. Used to calculate how long a line of text can be.
79 80 81 |
# File 'lib/prawn/document/column_box.rb', line 79 def width super / @columns - @spacer end |
#width_of_column ⇒ Object
Column width including the spacer.
85 86 87 |
# File 'lib/prawn/document/column_box.rb', line 85 def width_of_column width + @spacer end |