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
#document, #parent, #total_left_padding, #total_right_padding
Instance Method Summary collapse
-
#initialize(document, 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, #add_left_padding, #add_right_padding, #anchor, #bottom, #bottom_left, #bottom_right, #deep_copy, #height, #indent, #left, #reference_bounds, restore_deep_copy, #right, #stretchy?, #subtract_left_padding, #subtract_right_padding, #top, #top_left, #top_right
Constructor Details
#initialize(document, parent, point, options = {}) ⇒ ColumnBox
:nodoc:
49 50 51 52 53 54 |
# File 'lib/prawn/document/column_box.rb', line 49 def initialize(document, parent, point, ={}) #:nodoc: super @columns = [:columns] || 3 @spacer = [:spacer] || @document.font_size @current_column = 0 end |
Instance Method Details
#left_side ⇒ Object
x coordinate of the left edge of the current column
71 72 73 |
# File 'lib/prawn/document/column_box.rb', line 71 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.
84 85 86 87 88 89 90 |
# File 'lib/prawn/document/column_box.rb', line 84 def move_past_bottom @current_column = (@current_column + 1) % @columns @document.y = @y if 0 == @current_column @document.start_new_page end end |
#right_side ⇒ Object
x co-orordinate of the right edge of the current column
77 78 79 80 |
# File 'lib/prawn/document/column_box.rb', line 77 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.
59 60 61 |
# File 'lib/prawn/document/column_box.rb', line 59 def width super / @columns - @spacer end |
#width_of_column ⇒ Object
Column width including the spacer.
65 66 67 |
# File 'lib/prawn/document/column_box.rb', line 65 def width_of_column width + @spacer end |