Sha256: fcd3ce7063382f831489453a5032fd5aa92bec46579d0ed099500d0e5825da0f

Contents?: true

Size: 315 Bytes

Versions: 1

Compression:

Stored size: 315 Bytes

Contents


class String
  def word_count
    self.split(' ').length
  end

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

  def unique_word_count
    self.unique_words.length
  end

  def word_frequencies
    frequency = Hash.new(0)
    self.split(' ').each { |word| frequency[word.to_sym] += 1 }
    frequency
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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