Class: Prawn::Document::ColumnBox

Inherits:
BoundingBox show all
Defined in:
lib/prawn/document/column_box.rb

Instance Method Summary collapse

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

Returns a new instance of ColumnBox.



61
62
63
64
65
66
# File 'lib/prawn/document/column_box.rb', line 61

def initialize(parent, point, options={})
  super
  @columns = options[:columns] || 3
  @spacer  = options[:spacer]  || @parent.font_size
  @current_column = 0
end

Instance Method Details

#left_sideObject

x coordinate of the left edge of the current column



81
82
83
# File 'lib/prawn/document/column_box.rb', line 81

def left_side
  absolute_left + (width_of_column * @current_column)
end

#move_past_bottomObject

:nodoc:



92
93
94
95
96
97
98
# File 'lib/prawn/document/column_box.rb', line 92

def move_past_bottom #:nodoc:
  @current_column = (@current_column + 1) % @columns
  @parent.y = @y
  if 0 == @current_column
    @parent.start_new_page
  end
end

#right_sideObject

x co-orordinate of the right edge of the current column



87
88
89
90
# File 'lib/prawn/document/column_box.rb', line 87

def right_side
  columns_from_right = @columns - (1 + @current_column)
  absolute_right - (width_of_column * columns_from_right)
end

#widthObject

The column width, not the width of the whole box. Used to calculate how long a line of text can be.



71
72
73
# File 'lib/prawn/document/column_box.rb', line 71

def width
  super / @columns - @spacer
end

#width_of_columnObject



75
76
77
# File 'lib/prawn/document/column_box.rb', line 75

def width_of_column
  width + @spacer
end