Module: Prawn::Core::Text::Formatted::Wrap

Included in:
Text::Formatted::Box
Defined in:
lib/prawn/core/text/formatted/wrap.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#initialize(array, options) ⇒ Object



10
11
12
13
# File 'lib/prawn/core/text/formatted/wrap.rb', line 10

def initialize(array, options)
  @line_wrap = Prawn::Core::Text::Formatted::LineWrap.new
  @arranger = Prawn::Core::Text::Formatted::Arranger.new(@document)
end

#wrap(array) ⇒ Object

See the developer documentation for Prawn::Core::Text#wrap

Formatted#wrap should set the following variables:

<tt>@line_height</tt>::
     the height of the tallest fragment in the last printed line
<tt>@descender</tt>::
     the descender height of the tallest fragment in the last
     printed line
<tt>@ascender</tt>::
     the ascender heigth of the tallest fragment in the last
     printed line
<tt>@baseline_y</tt>::
    the baseline of the current line
<tt>@nothing_printed</tt>::
    set to true until something is printed, then false
<tt>@everything_printed</tt>::
    set to false until everything printed, then true

Returns any formatted text that was not printed



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/prawn/core/text/formatted/wrap.rb', line 36

def wrap(array) #:nodoc:
  initialize_wrap(array)

  stop = false
  while !stop
    @line_wrap.wrap_line(:document => @document,
                         :kerning => @kerning,
                         :width => available_width,
                         :arranger => @arranger)

    if enough_height_for_this_line?
      move_baseline_down
      print_line
    else
      stop = true
    end

    stop ||= @single_line || @arranger.finished?
  end
  @text = @printed_lines.join("\n")
  @everything_printed = @arranger.finished?
  @arranger.unconsumed
end