Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/string-stats-bgw.rb

Instance Method Summary collapse

Instance Method Details

#unique_word_countObject



11
12
13
# File 'lib/string-stats-bgw.rb', line 11

def unique_word_count
  array = self.split(" ").uniq.length
end

#unique_wordsObject



7
8
9
# File 'lib/string-stats-bgw.rb', line 7

def unique_words
  array = self.split(" ").uniq
end

#word_countObject



3
4
5
# File 'lib/string-stats-bgw.rb', line 3

def word_count
  array = self.split(" ").length
end

#word_frequenciesObject



15
16
17
18
19
20
21
22
23
# 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