class Prawn::Document::MultiBox

A MultiBox is specified by 2 Boxes and spans the areas between.

@group Experimental API

Attributes

pdf[R]

Public Class Methods

new(pdf, box1, box2) click to toggle source
# File lib/prawn/grid.rb, line 218
def initialize(pdf, box1, box2)
  @pdf = pdf
  @boxes = [box1, box2]
end

Public Instance Methods

bottom() click to toggle source
# File lib/prawn/grid.rb, line 257
def bottom
  bottom_box.bottom
end
bottom_left() click to toggle source
# File lib/prawn/grid.rb, line 269
def bottom_left
  [left, bottom]
end
bottom_right() click to toggle source
# File lib/prawn/grid.rb, line 273
def bottom_right
  [right, bottom]
end
bounding_box(&blk) click to toggle source
# File lib/prawn/grid.rb, line 277
def bounding_box(&blk)
  pdf.bounding_box(top_left, width: width, height: height, &blk)
end
gutter() click to toggle source
# File lib/prawn/grid.rb, line 241
def gutter
  @boxes[0].gutter
end
height() click to toggle source
# File lib/prawn/grid.rb, line 237
def height
  top_box.top - bottom_box.bottom
end
left() click to toggle source
# File lib/prawn/grid.rb, line 245
def left
  left_box.left
end
name() click to toggle source
# File lib/prawn/grid.rb, line 225
def name
  @boxes.map(&:name).join(':')
end
right() click to toggle source
# File lib/prawn/grid.rb, line 249
def right
  right_box.right
end
show(grid_color = 'CCCCCC') click to toggle source
# File lib/prawn/grid.rb, line 281
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
# File lib/prawn/grid.rb, line 253
def top
  top_box.top
end
top_left() click to toggle source
# File lib/prawn/grid.rb, line 261
def top_left
  [left, top]
end
top_right() click to toggle source
# File lib/prawn/grid.rb, line 265
def top_right
  [right, top]
end
total_height() click to toggle source
# File lib/prawn/grid.rb, line 229
def total_height
  @boxes[0].total_height
end
width() click to toggle source
# File lib/prawn/grid.rb, line 233
def width
  right_box.right - left_box.left
end

Private Instance Methods

bottom_box() click to toggle source
# File lib/prawn/grid.rb, line 307
def bottom_box
  @bottom_box ||= @boxes.min_by(&:bottom)
end
left_box() click to toggle source
# File lib/prawn/grid.rb, line 295
def left_box
  @left_box ||= @boxes.min_by(&:left)
end
right_box() click to toggle source
# File lib/prawn/grid.rb, line 299
def right_box
  @right_box ||= @boxes.max_by(&:right)
end
top_box() click to toggle source
# File lib/prawn/grid.rb, line 303
def top_box
  @top_box ||= @boxes.max_by(&:top)
end