Class: Prawn::Document::LazyBoundingBox
- Inherits:
-
BoundingBox
- Object
- BoundingBox
- Prawn::Document::LazyBoundingBox
- Defined in:
- lib/prawn/document/bounding_box.rb
Instance Method Summary collapse
-
#action(&block) ⇒ Object
Defines the block to be executed by LazyBoundingBox#draw.
-
#draw ⇒ Object
Sets Document#bounds to use the LazyBoundingBox for its bounds, runs the block specified by LazyBoundingBox#action, and then restores the original bounds of the document.
Methods inherited from BoundingBox
#absolute_bottom, #absolute_bottom_left, #absolute_bottom_right, #absolute_left, #absolute_right, #absolute_top, #absolute_top_left, #absolute_top_right, #anchor, #bottom, #bottom_left, #bottom_right, #height, #initialize, #left, #right, #stretchy?, #top, #top_left, #top_right, #width
Constructor Details
This class inherits a constructor from Prawn::Document::BoundingBox
Instance Method Details
#action(&block) ⇒ Object
Defines the block to be executed by LazyBoundingBox#draw. Usually, this will be used via a higher level interface.
See the documentation for Document#lazy_bounding_box, Document#header, and Document#footer
332 333 334 |
# File 'lib/prawn/document/bounding_box.rb', line 332 def action(&block) @action = block end |
#draw ⇒ Object
Sets Document#bounds to use the LazyBoundingBox for its bounds, runs the block specified by LazyBoundingBox#action, and then restores the original bounds of the document.
340 341 342 343 344 345 346 347 348 |
# File 'lib/prawn/document/bounding_box.rb', line 340 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 |