class Prawn::Document::GridBox
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.
@group Experimental API
Attributes
pdf[R]
Public Class Methods
new(pdf, i, j)
click to toggle source
# File lib/prawn/grid.rb, line 114 def initialize(pdf, i, j) @pdf = pdf @i = i @j = j end
Public Instance Methods
bottom()
click to toggle source
y-coordinate of the bottom
# File lib/prawn/grid.rb, line 163 def bottom @bottom ||= top - height end
bottom_left()
click to toggle source
x,y coordinates of bottom left corner
# File lib/prawn/grid.rb, line 178 def bottom_left [left, bottom] end
bottom_right()
click to toggle source
x,y coordinates of bottom right corner
# File lib/prawn/grid.rb, line 183 def bottom_right [right, bottom] end
bounding_box(&blk)
click to toggle source
Creates a standard bounding box based on the grid box.
# File lib/prawn/grid.rb, line 188 def bounding_box(&blk) pdf.bounding_box(top_left, width: width, height: height, &blk) end
gutter()
click to toggle source
Width of the gutter
# File lib/prawn/grid.rb, line 143 def gutter grid.gutter.to_f end
height()
click to toggle source
Height of a box
# File lib/prawn/grid.rb, line 138 def height grid.row_height.to_f end
left()
click to toggle source
x-coordinate of left side
# File lib/prawn/grid.rb, line 148 def left @left ||= (width + grid.column_gutter) * @j.to_f end
name()
click to toggle source
Mostly diagnostic method that outputs the name of a box as col_num, row_num
# File lib/prawn/grid.rb, line 123 def name "#{@i},#{@j}" end
right()
click to toggle source
x-coordinate of right side
# File lib/prawn/grid.rb, line 153 def right @right ||= left + width end
show(grid_color = 'CCCCCC')
click to toggle source
Diagnostic method
# File lib/prawn/grid.rb, line 193 def show(grid_color = 'CCCCCC') bounding_box do original_stroke_color = pdf.stroke_color pdf.stroke_color = grid_color pdf.text name pdf.stroke_bounds pdf.stroke_color = original_stroke_color end end
top()
click to toggle source
y-coordinate of the top
# File lib/prawn/grid.rb, line 158 def top @top ||= total_height - ((height + grid.row_gutter) * @i.to_f) end
top_left()
click to toggle source
x,y coordinates of top left corner
# File lib/prawn/grid.rb, line 168 def top_left [left, top] end
top_right()
click to toggle source
x,y coordinates of top right corner
# File lib/prawn/grid.rb, line 173 def top_right [right, top] end
total_height()
click to toggle source
:nodoc
# File lib/prawn/grid.rb, line 128 def total_height pdf.bounds.height.to_f end
width()
click to toggle source
Width of a box
# File lib/prawn/grid.rb, line 133 def width grid.column_width.to_f end
Private Instance Methods
grid()
click to toggle source
# File lib/prawn/grid.rb, line 207 def grid pdf.grid end