Object
A Box is a class that represents a bounded area of a page. A Grid object has methods that allow easy access to the coordinates of its corners, which can be plugged into most existing prawnmethods.
y-coordinate of the bottom
# File lib/prawn/layout/grid.rb, line 142 def bottom @bottom ||= top - height end
x,y coordinates of bottom left corner
# File lib/prawn/layout/grid.rb, line 157 def bottom_left [left, bottom] end
x,y coordinates of bottom right corner
# File lib/prawn/layout/grid.rb, line 162 def bottom_right [right, bottom] end
Creates a standard bounding box based on the grid box.
# File lib/prawn/layout/grid.rb, line 167 def bounding_box(&blk) pdf.bounding_box(top_left, :width => width, :height => height, &blk) end
Width of the gutter
# File lib/prawn/layout/grid.rb, line 122 def gutter grid.gutter.to_f end
Height of a box
# File lib/prawn/layout/grid.rb, line 117 def height grid.row_height.to_f end
x-coordinate of left side
# File lib/prawn/layout/grid.rb, line 127 def left @left ||= (width + grid.column_gutter) * @j.to_f end
Mostly diagnostic method that outputs the name of a box as col_num, row_num
# File lib/prawn/layout/grid.rb, line 102 def name "#{@i.to_s},#{@j.to_s}" end
x-coordinate of right side
# File lib/prawn/layout/grid.rb, line 132 def right @right ||= left + width end
Diagnostic method
# File lib/prawn/layout/grid.rb, line 172 def show(grid_color = "CCCCCC") self.bounding_box do original_stroke_color = pdf.stroke_color pdf.stroke_color = grid_color pdf.text self.name pdf.stroke_bounds pdf.stroke_color = original_stroke_color end end
y-coordinate of the top
# File lib/prawn/layout/grid.rb, line 137 def top @top ||= total_height - ((height + grid.row_gutter) * @i.to_f) end
x,y coordinates of top left corner
# File lib/prawn/layout/grid.rb, line 147 def top_left [left, top] end
x,y coordinates of top right corner
# File lib/prawn/layout/grid.rb, line 152 def top_right [right, top] end
Generated with the Darkfish Rdoc Generator 2.