Class: Prawn::Document::MultiBox
- Inherits:
-
Object
- Object
- Prawn::Document::MultiBox
- Defined in:
- lib/prawn/grid.rb
Overview
A MultiBox is specified by 2 Boxes and spans the areas between.
Experimental API collapse
-
#bottom ⇒ Float
y-coordinate of the bottom.
-
#bottom_left ⇒ Array(Float, Float)
x,y coordinates of bottom left corner.
-
#bottom_right ⇒ Array(Float, Float)
x,y coordinates of bottom right corner.
-
#bounding_box { ... } ⇒ void
Creates a standard bounding box based on the grid box.
-
#gutter ⇒ Float
Width of the gutter.
-
#height ⇒ Float
Height of a box.
-
#initialize(pdf, box1, box2) ⇒ MultiBox
constructor
A new instance of MultiBox.
-
#left ⇒ Float
x-coordinate of left side.
-
#name ⇒ String
Mostly diagnostic method that outputs the name of a box.
-
#right ⇒ Float
x-coordinate of right side.
-
#show(grid_color = 'CCCCCC') ⇒ void
Drawn the box.
-
#top ⇒ Float
y-coordinate of the top.
-
#top_left ⇒ Array(Float, Float)
x,y coordinates of top left corner.
-
#top_right ⇒ Array(Float, Float)
x,y coordinates of top right corner.
-
#width ⇒ Float
Width of a box.
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
#bottom ⇒ Float
y-coordinate of the bottom.
364 365 366 |
# File 'lib/prawn/grid.rb', line 364 def bottom bottom_box.bottom end |
#bottom_left ⇒ Array(Float, Float)
x,y coordinates of bottom left corner.
385 386 387 |
# File 'lib/prawn/grid.rb', line 385 def bottom_left [left, bottom] end |
#bottom_right ⇒ Array(Float, Float)
x,y coordinates of bottom right corner.
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.
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 |
#gutter ⇒ Float
Width of the gutter.
336 337 338 |
# File 'lib/prawn/grid.rb', line 336 def gutter @boxes[0].gutter end |
#height ⇒ Float
Height of a box.
329 330 331 |
# File 'lib/prawn/grid.rb', line 329 def height top_box.top - bottom_box.bottom end |
#left ⇒ Float
x-coordinate of left side.
343 344 345 |
# File 'lib/prawn/grid.rb', line 343 def left left_box.left end |
#name ⇒ String
Mostly diagnostic method that outputs the name of a box.
310 311 312 |
# File 'lib/prawn/grid.rb', line 310 def name @boxes.map(&:name).join(':') end |
#right ⇒ Float
x-coordinate of right side.
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.
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 |
#top ⇒ Float
y-coordinate of the top.
357 358 359 |
# File 'lib/prawn/grid.rb', line 357 def top top_box.top end |
#top_left ⇒ Array(Float, Float)
x,y coordinates of top left corner.
371 372 373 |
# File 'lib/prawn/grid.rb', line 371 def top_left [left, top] end |
#top_right ⇒ Array(Float, Float)
x,y coordinates of top right corner.
378 379 380 |
# File 'lib/prawn/grid.rb', line 378 def top_right [right, top] end |
#width ⇒ Float
Width of a box.
322 323 324 |
# File 'lib/prawn/grid.rb', line 322 def width right_box.right - left_box.left end |