class Prawn::Document::LazyBoundingBox

Public Instance Methods

action(&block) click to toggle source

Defines the block to be executed by #draw. Usually, this will be used via a higher level interface.

See the documentation for Prawn::Document#lazy_bounding_box, Document#header, and Document#footer

# File lib/prawn/layout/page.rb, line 56
def action(&block)
  @action = block
end
draw() click to toggle source

Sets Document#bounds to use the LazyBoundingBox for its bounds, runs the block specified by #action, and then restores the original bounds of the document.

# File lib/prawn/layout/page.rb, line 64
def draw
  @parent.mask(:y) do  
    parent_box = @parent.bounds  
    @parent.bounds = self    
    @parent.y = absolute_top
    @action.call   
    @parent.bounds = parent_box
  end
end