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.



299
300
301
302
# File 'lib/prawn/grid.rb', line 299

def initialize(pdf, box1, box2)
  @pdf = pdf
  @boxes = [box1, box2]
end

Instance Method Details

#bottomFloat

y-coordinate of the bottom.

Returns:

  • (Float)


364
365
366
# File 'lib/prawn/grid.rb', line 364

def bottom
  bottom_box.bottom
end

#bottom_leftArray(Float, Float)

x,y coordinates of bottom left corner.

Returns:

  • (Array(Float, Float))


385
386
387
# File 'lib/prawn/grid.rb', line 385

def bottom_left
  [left, bottom]
end

#bottom_rightArray(Float, Float)

x,y coordinates of bottom right corner.

Returns:

  • (Array(Float, Float))


392
393
394
# File 'lib/prawn/grid.rb', line 392

def bottom_right
  [right, bottom]
end

#bounding_box { ... } ⇒ void

This method returns an undefined value.

Creates a standard bounding box based on the grid box.

Yields:



400
401
402
# File 'lib/prawn/grid.rb', line 400

def bounding_box(&blk)
  pdf.bounding_box(top_left, width: width, height: height, &blk)
end

#gutterFloat

Width of the gutter.

Returns:

  • (Float)


336
337
338
# File 'lib/prawn/grid.rb', line 336

def gutter
  @boxes[0].gutter
end

#heightFloat

Height of a box.

Returns:

  • (Float)


329
330
331
# File 'lib/prawn/grid.rb', line 329

def height
  top_box.top - bottom_box.bottom
end

#leftFloat

x-coordinate of left side.

Returns:

  • (Float)


343
344
345
# File 'lib/prawn/grid.rb', line 343

def left
  left_box.left
end

#nameString

Mostly diagnostic method that outputs the name of a box.

Returns:

  • (String)


310
311
312
# File 'lib/prawn/grid.rb', line 310

def name
  @boxes.map(&:name).join(':')
end

#rightFloat

x-coordinate of right side.

Returns:

  • (Float)


350
351
352
# File 'lib/prawn/grid.rb', line 350

def right
  right_box.right
end

#show(grid_color = 'CCCCCC') ⇒ void

This method returns an undefined value.

Drawn the box. Diagnostic method.

Parameters:

  • grid_color (Color) (defaults to: 'CCCCCC')


408
409
410
411
412
413
414
415
416
417
418
# File 'lib/prawn/grid.rb', line 408

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

#topFloat

y-coordinate of the top.

Returns:

  • (Float)


357
358
359
# File 'lib/prawn/grid.rb', line 357

def top
  top_box.top
end

#top_leftArray(Float, Float)

x,y coordinates of top left corner.

Returns:

  • (Array(Float, Float))


371
372
373
# File 'lib/prawn/grid.rb', line 371

def top_left
  [left, top]
end

#top_rightArray(Float, Float)

x,y coordinates of top right corner.

Returns:

  • (Array(Float, Float))


378
379
380
# File 'lib/prawn/grid.rb', line 378

def top_right
  [right, top]
end

#widthFloat

Width of a box.

Returns:

  • (Float)


322
323
324
# File 'lib/prawn/grid.rb', line 322

def width
  right_box.right - left_box.left
end