class String

Public Instance Methods

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