class String
Public Instance Methods
unique_word_count()
click to toggle source
# File lib/string-stats-rh.rb, line 12 def unique_word_count self.unique_words.length end
unique_words()
click to toggle source
# File lib/string-stats-rh.rb, line 8 def unique_words self.split(' ').uniq end
word_count()
click to toggle source
# File lib/string-stats-rh.rb, line 4 def word_count self.split(' ').length end
word_frequencies()
click to toggle source
# 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