Sha256: 274449d51168fea7ae9787eefa80d8bde5ad364c6bacc1171595638ab80ea508
Contents?: true
Size: 415 Bytes
Versions: 1
Compression:
Stored size: 415 Bytes
Contents
class String def word_count array = self.split(" ").length end def unique_words array = self.split(" ").uniq end def unique_word_count array = self.split(" ").uniq.length end 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
string-stats-bgw-0.0.0 | lib/string-stats-bgw.rb |