Sha256: ca2806a79c3c50678bd5e2f991a09ead216e83f9423a6f03ab5bea75f1376f3e

Contents?: true

Size: 369 Bytes

Versions: 1

Compression:

Stored size: 369 Bytes

Contents

class String

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

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

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

	def word_frequencies
		words = self.split(" ")

		freq = {}

		words.each do |word|
			freq[word.to_sym] ||= 0
			freq[word.to_sym] += 1
		end

		freq.sort_by {|word, frequency| frequency}

	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
string-stats-mc-0.1.0 lib/string-stats-mc.rb