Class: Syllabize::Counter
- Inherits:
-
Object
- Object
- Syllabize::Counter
- Defined in:
- lib/syllabize.rb
Constant Summary collapse
- CONSONANTS =
/[bcdfghjklmnpqrstvwxz]/i- VOWELS =
/[aeiou]/i- LE_VOWEL_SOUND =
/((le)\z)|((le(d|r|s))|(ling)\z)/i- DIPHTHONGS =
/ou|ie|oo|oi|ea|ee|ai|ae/i- Y_AS_VOWEL =
/[^yY][yY]/- RE_VOWEL =
/(^re[aeiou])/i
Instance Attribute Summary collapse
-
#exceptions_file ⇒ Object
Returns the value of attribute exceptions_file.
-
#word ⇒ Object
Returns the value of attribute word.
Instance Method Summary collapse
- #count_syllables ⇒ Object
-
#initialize(word) ⇒ Counter
constructor
A new instance of Counter.
Constructor Details
#initialize(word) ⇒ Counter
Returns a new instance of Counter.
9 10 11 12 13 |
# File 'lib/syllabize.rb', line 9 def initialize(word) @word = word handle_non_string_input load_exceptions end |
Instance Attribute Details
#exceptions_file ⇒ Object
Returns the value of attribute exceptions_file.
7 8 9 |
# File 'lib/syllabize.rb', line 7 def exceptions_file @exceptions_file end |
#word ⇒ Object
Returns the value of attribute word.
7 8 9 |
# File 'lib/syllabize.rb', line 7 def word @word end |
Instance Method Details
#count_syllables ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/syllabize.rb', line 22 def count_syllables return handle_exceptions if exceptions.keys.include?(word) @syllables = count_vowels handle_additions handle_subtractions @syllables <= 1 ? 1 : @syllables end |