Class: Prawn::Document::MultiBox

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/grid.rb

Overview

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

Experimental API collapse

Constructor Details

#initialize(pdf, box1, box2) ⇒ MultiBox

Returns a new instance of MultiBox.

Source Code
lib/prawn/grid.rb, line 299
299
def initialize(pdf, box1, box2)
300
  @pdf = pdf
301
  @boxes = [box1, box2]
302
end

Instance Method Details

#bottomFloat

y-coordinate of the bottom.

Returns:

  • (Float)
Source Code
lib/prawn/grid.rb, line 364
364
def bottom
365
  bottom_box.bottom
366
end

#bottom_leftArray(Float, Float)

x,y coordinates of bottom left corner.

Returns:

  • (Array(Float, Float))
Source Code
lib/prawn/grid.rb, line 385
385
def bottom_left
386
  [left, bottom]
387
end

#bottom_rightArray(Float, Float)

x,y coordinates of bottom right corner.

Returns:

  • (Array(Float, Float))
Source Code
lib/prawn/grid.rb, line 392
392
def bottom_right
393
  [right, bottom]
394
end

#bounding_box { ... } ⇒ void

This method returns an undefined value.

Creates a standard bounding box based on the grid box.

Yields:

Source Code
lib/prawn/grid.rb, line 400
400
def bounding_box(&blk)
401
  pdf.bounding_box(top_left, width: width, height: height, &blk)
402
end

#gutterFloat

Width of the gutter.

Returns:

  • (Float)
Source Code
lib/prawn/grid.rb, line 336
336
def gutter
337
  @boxes[0].gutter
338
end

#heightFloat

Height of a box.

Returns:

  • (Float)
Source Code
lib/prawn/grid.rb, line 329
329
def height
330
  top_box.top - bottom_box.bottom
331
end

#leftFloat

x-coordinate of left side.

Returns:

  • (Float)
Source Code
lib/prawn/grid.rb, line 343
343
def left
344
  left_box.left
345
end

#nameString

Mostly diagnostic method that outputs the name of a box.

Returns:

  • (String)
Source Code
lib/prawn/grid.rb, line 310
310
def name
311
  @boxes.map(&:name).join(':')
312
end

#rightFloat

x-coordinate of right side.

Returns:

  • (Float)
Source Code
lib/prawn/grid.rb, line 350
350
def right
351
  right_box.right
352
end

#show(grid_color = 'CCCCCC') ⇒ void

This method returns an undefined value.

Drawn the box. Diagnostic method.

Parameters:

  • grid_color (Color) (defaults to: 'CCCCCC')
Source Code
lib/prawn/grid.rb, line 408
408
def show(grid_color = 'CCCCCC')
409
  bounding_box do
410
    original_stroke_color = pdf.stroke_color
411
412
    pdf.stroke_color = grid_color
413
    pdf.text(name)
414
    pdf.stroke_bounds
415
416
    pdf.stroke_color = original_stroke_color
417
  end
418
end

#topFloat

y-coordinate of the top.

Returns:

  • (Float)
Source Code
lib/prawn/grid.rb, line 357
357
def top
358
  top_box.top
359
end

#top_leftArray(Float, Float)

x,y coordinates of top left corner.

Returns:

  • (Array(Float, Float))
Source Code
lib/prawn/grid.rb, line 371
371
def top_left
372
  [left, top]
373
end

#top_rightArray(Float, Float)

x,y coordinates of top right corner.

Returns:

  • (Array(Float, Float))
Source Code
lib/prawn/grid.rb, line 378
378
def top_right
379
  [right, top]
380
end

#widthFloat

Width of a box.

Returns:

  • (Float)
Source Code
lib/prawn/grid.rb, line 322
322
def width
323
  right_box.right - left_box.left
324
end