Class: Hyphenator

Inherits:
Object show all
Defined in:
lib/hyphenator.rb

Constant Summary collapse

ACCENTED_CHARS =
/[çãâäõáéíóúêôàü]/

Instance Method Summary collapse

Constructor Details

#initializeHyphenator

Returns a new instance of Hyphenator.



8
9
10
11
12
13
14
15
16
# File 'lib/hyphenator.rb', line 8

def initialize
  @hyphenator = Text::Hyphen.new do |h|
    h.left = 0
    h.right = 0
    h.language = 'pt'
  end

  @orig_accented_chars_pos = Hash.new
end

Instance Method Details

#hyphenate(word) ⇒ Object



18
19
20
21
22
# File 'lib/hyphenator.rb', line 18

def hyphenate(word)
  word = remove_accents word
  hyphenated_raw = @hyphenator.visualize word
  hyphenated_final = put_accents_back word, hyphenated_raw
end