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 Prawn methods.
@group Experimental API
Attributes
@private
Public Class Methods
Source
# File lib/prawn/grid.rb, line 168 def initialize(pdf, rows, columns) @pdf = pdf @rows = rows @columns = columns end
Public Instance Methods
Source
# File lib/prawn/grid.rb, line 232 def bottom @bottom ||= top - height end
y-coordinate of the bottom.
@return [Float]
Source
# File lib/prawn/grid.rb, line 253 def bottom_left [left, bottom] end
x,y coordinates of bottom left corner.
@return [Array(Float, Float)]
Source
# File lib/prawn/grid.rb, line 260 def bottom_right [right, bottom] end
x,y coordinates of bottom right corner.
@return [Array(Float, Float)]
Source
# File lib/prawn/grid.rb, line 268 def bounding_box(&blk) pdf.bounding_box(top_left, width: width, height: height, &blk) end
Creates a standard bounding box based on the grid box.
@yield @return [void]
Source
# File lib/prawn/grid.rb, line 204 def gutter Float(grid.gutter) end
Width of the gutter.
@return [Float]
Source
# File lib/prawn/grid.rb, line 197 def height Float(grid.row_height) end
Height of a box.
@return [Float]
Source
# File lib/prawn/grid.rb, line 211 def left @left ||= (width + grid.column_gutter) * Float(@columns) end
x-coordinate of left side.
@return [Float]
Source
# File lib/prawn/grid.rb, line 178 def name "#{@rows},#{@columns}" end
Mostly diagnostic method that outputs the name of a box as col_num, row_num
@return [String]
Source
# File lib/prawn/grid.rb, line 218 def right @right ||= left + width end
x-coordinate of right side.
@return [Float]
Source
# File lib/prawn/grid.rb, line 276 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
Drawn the box. Diagnostic method.
@param grid_color [Color] @return [void]
Source
# File lib/prawn/grid.rb, line 225 def top @top ||= total_height - ((height + grid.row_gutter) * Float(@rows)) end
y-coordinate of the top.
@return [Float]
Source
# File lib/prawn/grid.rb, line 239 def top_left [left, top] end
x,y coordinates of top left corner.
@return [Array(Float, Float)]
Source
# File lib/prawn/grid.rb, line 246 def top_right [right, top] end
x,y coordinates of top right corner.
@return [Array(Float, Float)]
Source
# File lib/prawn/grid.rb, line 183 def total_height Float(pdf.bounds.height) end
@private
Source
# File lib/prawn/grid.rb, line 190 def width Float(grid.column_width) end
Width of a box.
@return [Float]