class Text::Reform::BreakHyphenator

This word-breaker uses a class that implements the API presented by TeX::Hyphen and Text::Hyphen modules.

Public Class Methods

new(hyphenator) click to toggle source
# File lib/text/reform.rb, line 1524
def initialize(hyphenator)
  @hyphenator = hyphenator
end

Public Instance Methods

break(str, initial_max_length, total_width) click to toggle source

Break a word using the provided hyphenation module that responds to hyphenate_to.

initial_max_length

The maximum size of the first part of the word that will remain on the first line.

total_width

The total width that can be appended to this first line.

# File lib/text/reform.rb, line 1535
def break(str, initial_max_length, total_width)
  res = @hyphenator.hyphenate_to(str, initial_max_length)
  res.map! { |ee| ee.nil? ? "" : ee }
  res
end