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|ay/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
-
#__dir__ ⇒ Object
for Ruby 1.9.
- #count_syllables ⇒ Object
-
#initialize(word) ⇒ Counter
constructor
A new instance of Counter.
Constructor Details
#initialize(word) ⇒ Counter
Returns a new instance of Counter.
8 9 10 11 12 |
# File 'lib/syllabize.rb', line 8 def initialize(word) @word = strip_punctuation(word) handle_non_string_input load_exceptions end |
Instance Attribute Details
#exceptions_file ⇒ Object
Returns the value of attribute exceptions_file.
6 7 8 |
# File 'lib/syllabize.rb', line 6 def exceptions_file @exceptions_file end |
#word ⇒ Object
Returns the value of attribute word.
6 7 8 |
# File 'lib/syllabize.rb', line 6 def word @word end |
Instance Method Details
#__dir__ ⇒ Object
for Ruby 1.9
32 33 34 |
# File 'lib/syllabize.rb', line 32 def __dir__ File.dirname(__FILE__) end |
#count_syllables ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/syllabize.rb', line 21 def count_syllables return handle_exceptions if exceptions.keys.include?(word) @syllables = count_vowels handle_additions handle_subtractions @syllables <= 1 ? 1 : @syllables end |