class Prawn::Document::ColumnBox
Implements the necessary functionality to allow {Document#column_box} to work.
Public Class Methods
Source
# File lib/prawn/document/column_box.rb, line 68 def initialize(document, parent, point, options = {}) super @columns = options[:columns] || 3 @spacer = options[:spacer] || @document.font_size @current_column = 0 @reflow_margins = options[:reflow_margins] end
@param point [Array(Number, Number)] @param options [Hash{Symbol => any}] @option options :width [Number]
width of the new column box, must be specified.
@option options :height [Number]
height of the new column box, stretchy box if omitted.
@option options :columns [Integer] (3) @option options :spacer [Number] (font_size) @option options :reflow_margins [Boolean] (false)
Prawn::Document::BoundingBox::new
Public Instance Methods
Source
# File lib/prawn/document/column_box.rb, line 149 def add_left_padding(left_padding) @total_left_padding += left_padding @x += left_padding end
@private @param left_padding [Number] @return [void]
Source
# File lib/prawn/document/column_box.rb, line 165 def add_right_padding(right_padding) @total_right_padding += right_padding end
@private @param right_padding [Number] @return [void]
Source
# File lib/prawn/document/column_box.rb, line 80 def bare_column_width (@width - (@spacer * (@columns - 1))) / @columns end
The column width, not the width of the whole box, before left and/or right padding.
@return [Number]
Source
# File lib/prawn/document/column_box.rb, line 109 def left width_of_column * @current_column end
Relative position of the left edge of the current column.
@return [Number]
Source
# File lib/prawn/document/column_box.rb, line 102 def left_side absolute_left + (width_of_column * @current_column) end
x coordinate of the left edge of the current column.
@return [Number]
Source
# File lib/prawn/document/column_box.rb, line 132 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
Moves to the next column or starts a new page if currently positioned at the rightmost column.
@return [void]
Source
# File lib/prawn/document/column_box.rb, line 124 def right left + width end
Relative position of the right edge of the current column.
@return [Number]
Source
# File lib/prawn/document/column_box.rb, line 116 def right_side columns_from_right = @columns - (1 + @current_column) absolute_right - (width_of_column * columns_from_right) end
x coordinate of the right edge of the current column.
@return [Number]
Source
# File lib/prawn/document/column_box.rb, line 157 def subtract_left_padding(left_padding) @total_left_padding -= left_padding @x -= left_padding end
@private @param left_padding [Number] @return [void]
Source
# File lib/prawn/document/column_box.rb, line 172 def subtract_right_padding(right_padding) @total_right_padding -= right_padding end
@private @param right_padding [Number] @return [void]
Source
# File lib/prawn/document/column_box.rb, line 88 def width bare_column_width - (@total_left_padding + @total_right_padding) end
The column width after padding. Used to calculate how long a line of text can be.
@return [Number]
Source
# File lib/prawn/document/column_box.rb, line 95 def width_of_column bare_column_width + @spacer end
Column width including the spacer.
@return [Number]