Class: Text::Reform::BreakHyphenator
- Inherits:
-
Object
- Object
- Text::Reform::BreakHyphenator
- Defined in:
- lib/text/reform.rb
Overview
This word-breaker uses a class that implements the API presented by TeX::Hyphen and Text::Hyphen modules.
Instance Method Summary collapse
-
#break(str, initial_max_length, total_width) ⇒ Object
Break a word using the provided hyphenation module that responds to #hyphenate_to.
-
#initialize(hyphenator) ⇒ BreakHyphenator
constructor
A new instance of BreakHyphenator.
Constructor Details
#initialize(hyphenator) ⇒ BreakHyphenator
Returns a new instance of BreakHyphenator.
1524 1525 1526 |
# File 'lib/text/reform.rb', line 1524 def initialize(hyphenator) @hyphenator = hyphenator end |
Instance Method Details
#break(str, initial_max_length, total_width) ⇒ Object
Break a word using the provided hyphenation module that responds to #hyphenate_to.
initial_max_lengthThe maximum size of the first part of the word that will remain on the first line.
total_widthThe total width that can be appended to this first line.
1535 1536 1537 1538 1539 |
# 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 |