Sha256: ba9f58caeb52df166a1e77e2f886a8887f4f81d214ea939a324069f7a34414ae

Contents?: true

Size: 326 Bytes

Versions: 7

Compression:

Stored size: 326 Bytes

Contents

class String
  
  def word_count
    return self.split.length
  end

  def unique_words
    return self.split.uniq
  end

  def unique_word_count
    return self.split.uniq.length
  end

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

end

Version data entries

7 entries across 7 versions & 7 rubygems

Version Path
string-stats-ahh-0.1.0.1 lib/string-stats-ah.rb
string-stats-dc-0.1.0 lib/string-stats-dc.rb
string-stats-cks-0.1.0 lib/string-stats-cks.rb
string-stats-rp-0.1.0 lib/string-stats-rp.rb
string-stats-ca-0.1.0 lib/string-stats-ca.rb
string-stats-bm-0.1.0 lib/string-stats-bm.rb
string-stats-df-0.1.0 lib/string-stats-df.rb