class String

Public Instance Methods

unique_word_count() click to toggle source
# File lib/string-stats-es.rb, line 11
def unique_word_count
        self.unique_words.length
end
unique_words() click to toggle source
# File lib/string-stats-es.rb, line 7
def unique_words
        self.split(" ").uniq
end
word_count() click to toggle source
# File lib/string-stats-es.rb, line 3
def word_count
        self.split(" ").length
end
word_frequencies() click to toggle source
# File lib/string-stats-es.rb, line 15
def word_frequencies
        words = self.split(" ")
        word_frequencies = {}
        words.each do |word|
                word_frequencies[word.to_sym] ||= 0
                word_frequencies[word.to_sym] += 1
        end
        return word_frequencies
end