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.



218
219
220
221
# File 'lib/prawn/grid.rb', line 218

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

Instance Attribute Details

#pdfObject (readonly)

Returns the value of attribute pdf.



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

def pdf
  @pdf
end

Instance Method Details

#bottomObject



257
258
259
# File 'lib/prawn/grid.rb', line 257

def bottom
  bottom_box.bottom
end

#bottom_leftObject



269
270
271
# File 'lib/prawn/grid.rb', line 269

def bottom_left
  [left, bottom]
end

#bottom_rightObject



273
274
275
# File 'lib/prawn/grid.rb', line 273

def bottom_right
  [right, bottom]
end

#bounding_box(&blk) ⇒ Object



277
278
279
# File 'lib/prawn/grid.rb', line 277

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

#gutterObject



241
242
243
# File 'lib/prawn/grid.rb', line 241

def gutter
  @boxes[0].gutter
end

#heightObject



237
238
239
# File 'lib/prawn/grid.rb', line 237

def height
  top_box.top - bottom_box.bottom
end

#leftObject



245
246
247
# File 'lib/prawn/grid.rb', line 245

def left
  left_box.left
end

#nameObject



225
226
227
# File 'lib/prawn/grid.rb', line 225

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

#rightObject



249
250
251
# File 'lib/prawn/grid.rb', line 249

def right
  right_box.right
end

#show(grid_color = 'CCCCCC') ⇒ Object



281
282
283
284
285
286
287
288
289
290
291
# 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

#topObject



253
254
255
# File 'lib/prawn/grid.rb', line 253

def top
  top_box.top
end

#top_leftObject



261
262
263
# File 'lib/prawn/grid.rb', line 261

def top_left
  [left, top]
end

#top_rightObject



265
266
267
# File 'lib/prawn/grid.rb', line 265

def top_right
  [right, top]
end

#total_heightObject



229
230
231
# File 'lib/prawn/grid.rb', line 229

def total_height
  @boxes[0].total_height
end

#widthObject



233
234
235
# File 'lib/prawn/grid.rb', line 233

def width
  right_box.right - left_box.left
end