class HexaPDF::Layout::BoxFitter

Parent

A BoxFitter instance contains an array of Frame objects and allows placing boxes one after the other in them. Such functionality is useful, for example, for boxes that provide multiple frames for content.

Usage

  • First one needs to add the frame objects via << or provide them on initialization.

  • Then use the fit method to fit boxes one after the other. No drawing is done.

  • Once all boxes have been fitted, the fit_results, remaining_boxes and success? methods can be used to get the result:

    • If there are no remaining boxes, all boxes were successfully fitted into the frames.

    • If there are remaining boxes but no fit results, the first box could not be fitted.

    • If there are remaining boxes and fit results, some boxes were able to fit.

Attributes

fit_results[R]

The Frame::FitResult objects for the successfully fitted objects in the order the boxes were fitted.

frames[R]

The array of frames inside of which the boxes should be laid out.

Use << to add additional frames.

remaining_boxes[R]

The boxes that could not be fitted into the frames.

Public Class Methods

new(frames = [])

Creates a new BoxFitter object for the given frames.

Public Instance Methods

<<(frame)

Add the given frame to the list of frames.

content_heights()

Returns an array with the heights of the content of each frame.

fit(box)

Fits the given box at the current location.

success?()

Returns true if all boxes were successfully fitted.