Class: Syllables

Inherits:
Object
  • Object
show all
Defined in:
lib/syllables.rb

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Syllables

Returns a new instance of Syllables.



10
11
12
13
14
# File 'lib/syllables.rb', line 10

def initialize(text)
  super()
  @words = text.gsub(/\W+/, ' ').split\
    .inject({}) {|r,word| r.merge({word.to_sym => count_syllables(word)})}
end

Instance Method Details

#to_hObject



16
17
18
# File 'lib/syllables.rb', line 16

def to_h
  @words
end