CleanWords
A clean (i.e. "kid friendly") random word generator.
Currently the word list varies in size from 4 to 12 letters in length and consists mostly of words for animals, food, plants, and buildings.
Installation
Add this line to your application's Gemfile:
gem 'clean_words'
And then execute:
$ bundle
Or install it yourself as:
$ gem install clean_words
Usage
words = CleanWords::Random.new
# Fetch a random word
words.fetch
#=> 'aspen'
# Fetch a number of random words
words.fetch(nil, 3)
#=> ['aspen', 'terrier', 'apple']
# Fetch a random word of a particular size
words.fetch(6)
#=> 'arctic'
# Fetch random words of an array of sizes
words.fetch([4,6], 2)
#=> ['arctic', 'fort']
# Fetch random words of a range of sizes
words.fetch((4..6), 4)
#=> ['fort', 'gopher', 'arctic', 'maple']
Contributing
- Fork it ( https://github.com/foraker/clean_words/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature')- NOTE: If adding words to
data/words.txt, please executeruby util/sanitize_list.rbfrom the project root before commiting.
- NOTE: If adding words to
- Push to the branch (
git push origin my-new-feature) - Create a new Pull Request