This gem adds one
word_count method to
Hash. It calls the Unix
wc system command to count the amount of words in a String or a Hash. Other ways to count words (using regexes) are unreliable for counting words in foreign languages.
# add this to your Gemfile gem "word_count" # and run bundle update
str = "the brown fox jumped over the lazy dog" str.word_count # => 8
Copyright (c) 2013 Atelier Convivialité.