Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string-stats-rh.rb
Instance Method Summary collapse
Instance Method Details
#unique_word_count ⇒ Object
12 13 14 |
# File 'lib/string-stats-rh.rb', line 12 def unique_word_count self.unique_words.length end |
#unique_words ⇒ Object
8 9 10 |
# File 'lib/string-stats-rh.rb', line 8 def unique_words self.split(' ').uniq end |
#word_count ⇒ Object
4 5 6 |
# File 'lib/string-stats-rh.rb', line 4 def word_count self.split(' ').length end |
#word_frequencies ⇒ Object
16 17 18 19 20 |
# File 'lib/string-stats-rh.rb', line 16 def word_frequencies frequency = Hash.new(0) self.split(' ').each { |word| frequency[word.to_sym] += 1 } frequency end |