class String

Public Instance Methods

unique_word_count() click to toggle source
# File lib/string-stats-befr.rb, line 11
def unique_word_count
        self.unique_words.length
end
unique_words() click to toggle source
# File lib/string-stats-befr.rb, line 7
def unique_words
        self.split(" ").uniq
end
word_count() click to toggle source
# File lib/string-stats-befr.rb, line 3
def word_count
        string = self.split(" ").length
end
word_frequencies() click to toggle source
# File lib/string-stats-befr.rb, line 15
def word_frequencies
        unique_words = self.unique_words
        all_words = self.split(" ")
        frequencies = {}

        unique_words.each do |word|
                frequencies[word.to_sym] = all_words.count(word)
        end
        return frequencies
end