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.
@private
Attributes
pdf[R]
Public Class Methods
new(pdf, i, j)
click to toggle source
# File lib/prawn/grid.rb, line 108 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 157 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 172 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 177 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 182 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 137 def gutter grid.gutter.to_f end
height()
click to toggle source
Height of a box
# File lib/prawn/grid.rb, line 132 def height grid.row_height.to_f end
left()
click to toggle source
x-coordinate of left side
# File lib/prawn/grid.rb, line 142 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 117 def name "#{@i.to_s},#{@j.to_s}" end
right()
click to toggle source
x-coordinate of right side
# File lib/prawn/grid.rb, line 147 def right @right ||= left + width end
show(grid_color = "CCCCCC")
click to toggle source
Diagnostic method
# File lib/prawn/grid.rb, line 187 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
top()
click to toggle source
y-coordinate of the top
# File lib/prawn/grid.rb, line 152 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 162 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 167 def top_right [right, top] end
total_height()
click to toggle source
:nodoc
# File lib/prawn/grid.rb, line 122 def total_height pdf.bounds.height.to_f end
width()
click to toggle source
Width of a box
# File lib/prawn/grid.rb, line 127 def width grid.column_width.to_f end
Private Instance Methods
grid()
click to toggle source
# File lib/prawn/grid.rb, line 200 def grid pdf.grid end