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

Experimental API collapse

Constructor Details

#initialize(pdf, box1, box2) ⇒ MultiBox

Returns a new instance of MultiBox.



216
217
218
219
# File 'lib/prawn/grid.rb', line 216

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

Instance Attribute Details

#pdfObject (readonly)

Returns the value of attribute pdf.



221
222
223
# File 'lib/prawn/grid.rb', line 221

def pdf
  @pdf
end

Instance Method Details

#bottomObject



255
256
257
# File 'lib/prawn/grid.rb', line 255

def bottom
  bottom_box.bottom
end

#bottom_leftObject



267
268
269
# File 'lib/prawn/grid.rb', line 267

def bottom_left
  [left, bottom]
end

#bottom_rightObject



271
272
273
# File 'lib/prawn/grid.rb', line 271

def bottom_right
  [right, bottom]
end

#bounding_box(&blk) ⇒ Object



275
276
277
# File 'lib/prawn/grid.rb', line 275

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

#gutterObject



239
240
241
# File 'lib/prawn/grid.rb', line 239

def gutter
  @boxes[0].gutter
end

#heightObject



235
236
237
# File 'lib/prawn/grid.rb', line 235

def height
  top_box.top - bottom_box.bottom
end

#leftObject



243
244
245
# File 'lib/prawn/grid.rb', line 243

def left
  left_box.left
end

#nameObject



223
224
225
# File 'lib/prawn/grid.rb', line 223

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

#rightObject



247
248
249
# File 'lib/prawn/grid.rb', line 247

def right
  right_box.right
end

#show(grid_color = 'CCCCCC') ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
# File 'lib/prawn/grid.rb', line 279

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

#topObject



251
252
253
# File 'lib/prawn/grid.rb', line 251

def top
  top_box.top
end

#top_leftObject



259
260
261
# File 'lib/prawn/grid.rb', line 259

def top_left
  [left, top]
end

#top_rightObject



263
264
265
# File 'lib/prawn/grid.rb', line 263

def top_right
  [right, top]
end

#total_heightObject



227
228
229
# File 'lib/prawn/grid.rb', line 227

def total_height
  @boxes[0].total_height
end

#widthObject



231
232
233
# File 'lib/prawn/grid.rb', line 231

def width
  right_box.right - left_box.left
end