Sha256: bdaed351dfdf44e5f9612eab4a07e2e0c0c2b3152c10522ece0cd514f66737ad
Contents?: true
Size: 523 Bytes
Versions: 2
Compression:
Stored size: 523 Bytes
Contents
module FemisHangman class Word def generate(difficulty) file = File.open('./dictionary.txt', 'r') rand(41211).times { file.gets } word = clean_word($_) file.close if confirm(difficulty, word) then word else generate(difficulty) end end def confirm(difficulty, word) if word.length > 4 * difficulty && word.length <= 4 * (difficulty + 1) true else false end end def clean_word(word) word.delete("\n") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
femis_hangman-0.1.3 | lib/femis_hangman/word.rb |
femis_hangman-0.1.2 | lib/femis_hangman/word.rb |