lib/prawn/document.rb
# Attempts to group the given block vertically within the current context.
# First attempts to render it in the current position on the current page.
# If that attempt overflows, it is tried anew after starting a new context
# (page or column). Returns a logically true value if the content fits in
# one page/column, false if a new page or column was needed.
#
# Raises CannotGroup if the provided content is too large to fit alone in
# the current page or column.
#
Attempts to group the given block vertically within the current context.
First attempts to render it in the current position on the current page.
If that attempt overflows, it is tried anew after starting a new context
(page or column). Returns a logically true value if the content fits in
one page/column, false if a new page or column was needed.

Raises CannotGroup if the provided content is too large to fit alone in
the current page or column.
Attempts to group the given block vertically within the current context . First attempts to render it in the current position on the current page . If that attempt overflows it is tried anew after starting a new context ( page or column ) . Returns a logically true value if the content fits in one page / column false if a new page or column was needed . Raises CannotGroup if the provided content is too large to fit alone in the current page or column .
def group(second_attempt=false)
      @bounding_box = SimpleDelegator.new(@bounding_box)
      @group_level ||= 0
      @root_group_second_attempt = second_attempt if @group_level == 0
      @group_level += 1
      def @bounding_box.move_past_bottom
        raise RollbackTransaction
      end
      starting_page = page_number
      starting_cursor = cursor
      starting_y = y
      previous_graphic_state = state.page.stack.stack.map{|g| GraphicState.new(g)}
      begin
        success = transaction { yield }
      ensure
        @bounding_box = @bounding_box.__getobj__ if @bounding_box.respond_to?(:__getobj__)
        @group_level -= 1
      end
      unless success
        if second_attempt
          go_to_page(starting_page)
          state.page.stack.stack = previous_graphic_state
          move_cursor_to(starting_cursor)
          yield
        elsif @group_level > 0
          go_to_page(starting_page)
          state.page.stack.stack = previous_graphic_state
          move_cursor_to(starting_cursor)
          yield
          if page_number > starting_page && !@root_group_second_attempt
            rollback
          end
        else
          if starting_y != @bounding_box.absolute_top || @bounding_box.is_a?(Prawn::Document::ColumnBox)
            @bounding_box.move_past_bottom
          else
            go_to_page(starting_page)
            state.page.stack.stack = previous_graphic_state
            move_cursor_to(starting_cursor)
          end
          group(@root_group_second_attempt=true) { yield }
        end
      end
      success
    end
def group ( second_attempt = false ) @bounding_box = SimpleDelegator . new ( @bounding_box ) @group_level ||= 0 @root_group_second_attempt = second_attempt if @group_level == 0 @group_level += 1 def @bounding_box . move_past_bottom raise RollbackTransaction end starting_page = page_number starting_cursor = cursor starting_y = y previous_graphic_state = state . page . stack . stack . map { | g | GraphicState . new ( g ) } begin success = transaction { yield } ensure @bounding_box = @bounding_box . __getobj__ if @bounding_box . respond_to? ( :__getobj__ ) @group_level -= 1 end unless success if second_attempt go_to_page ( starting_page ) state . page . stack . stack = previous_graphic_state move_cursor_to ( starting_cursor ) yield elsif @group_level > 0 go_to_page ( starting_page ) state . page . stack . stack = previous_graphic_state move_cursor_to ( starting_cursor ) yield if page_number > starting_page && ! @root_group_second_attempt rollback end else if starting_y != @bounding_box . absolute_top || @bounding_box . is_a? ( Prawn :: Document :: ColumnBox ) @bounding_box . move_past_bottom else go_to_page ( starting_page ) state . page . stack . stack = previous_graphic_state move_cursor_to ( starting_cursor ) end group ( @root_group_second_attempt = true ) { yield } end end success end
Attempts to group the given block vertically within the current context.
Attempts to group the given block vertically within the current context .
second_attempt
<not_specific>