Class: Prawn::Core::Text::Formatted::LineWrap
- Defined in:
- lib/prawn/core/text/formatted/line_wrap.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#wrap_line(options) ⇒ Object
Work in conjunction with the Prawn::Core::Formatted::Arranger defined in the :arranger option to determine what formatted text will fit within the width defined by the :width option.
Methods inherited from LineWrap
#consumed_char_count, #scan_pattern, #space_count, #width, #word_division_scan_pattern
Instance Method Details
#wrap_line(options) ⇒ Object
Work in conjunction with the Prawn::Core::Formatted::Arranger defined in the :arranger option to determine what formatted text will fit within the width defined by the :width option
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/prawn/core/text/formatted/line_wrap.rb', line 22 def wrap_line() initialize_line() while fragment = @arranger.next_string @output = "" preview = @arranger.preview_next_string fragment.lstrip! if @line_output.empty? && fragment != "\n" if @line_output.empty? && fragment.empty? && preview == "\n" # this line was just whitespace followed by a newline, which is # equivalent to just a newline @arranger.update_last_string("", "") next end if !add_fragment_to_line(fragment) fragment_finished(fragment, true) break end fragment_finished(fragment, preview == "\n" || preview.nil?) end @arranger.finalize_line @accumulated_width = @arranger.line_width @space_count = @arranger.space_count @arranger.line end |