Class: String

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

Instance Method Summary collapse

Instance Method Details

#unique_word_countObject



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

def unique_word_count
  return self.split.uniq.length
end

#unique_wordsObject



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

def unique_words
  return self.split.uniq
end

#word_countObject



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

def word_count
  return self.split.length
end

#word_frequenciesObject



15
16
17
18
19
20
21
# File 'lib/string-stats-cks.rb', line 15

def word_frequencies
  freq = Hash.new(0)
  self.split.each do |word|
    freq[word.to_sym] += 1
  end
  return freq
end