Class: Syllables
- Inherits:
-
Object
- Object
- Syllables
- Defined in:
- lib/syllables.rb
Instance Method Summary collapse
-
#initialize(text) ⇒ Syllables
constructor
A new instance of Syllables.
- #to_h ⇒ Object
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_h ⇒ Object
16 17 18 |
# File 'lib/syllables.rb', line 16 def to_h @words end |