class HexaPDF::Document::Layout::ChildrenCollector

end
end
column << document.layout.lorem_ipsum_box # adding a Box instance
column.text(“Text in column”)
list.column(columns: 3) do |column| # registered box name
list.image(image_path) # layout method without _box suffix
list.text_box(“Some text here”) # layout method
document.layout.box(:list) do |list| # list is a ChildrenCollector
Example:
children.
The special method #multiple allows adding multiple boxes as a single array to the collected
list, column, …
Any name registered with the configuration option layout.boxes.map.
suffix.
text, formatted_text, image, …
Any method accepted by the Layout class without the _box
text_box, formatted_text_box, image_box, …
Any method accepted by the Layout class.
#<<

This appends the given box to the list.
A box can be added to the list of collected children in the following ways:
to collect the children for the created box.
be seemlessly doable when creating the parent node. It is yieled, for example, by Layout#box
This class is used when a box can contain child boxes and the creation of such boxes should

def self.collect(layout)

Creates a children collector, yields it and then returns the collected children.
def self.collect(layout)
  collector = new(layout)
  yield(collector)
  collector.children
end

def <<(box)

Appends the given box to the list of collected children.
def <<(box)
  @children << box
end

def initialize(layout)

instance.
Create a new ChildrenCollector for the given +layout+ (a HexaPDF::Document::Layout)
def initialize(layout)
  @layout = layout
  @children = []
end

def method_missing(name, *args, **kwargs, &block)

:nodoc:
def method_missing(name, *args, **kwargs, &block)
  if @layout.box_creation_method?(name)
    box = @layout.send(name, *args, **kwargs, &block)
    @children << box
    box
  else
    super
  end
end

def multiple(&block)

the list of collected children.
Yields a ChildrenCollector instance and adds the collected children as a single array to
def multiple(&block)
  @children << self.class.collect(@layout, &block)
end

def respond_to_missing?(name, _private)

:nodoc:
def respond_to_missing?(name, _private)
  @layout.box_creation_method?(name) || super
end