Sha256: ada7713e79e34c172c8a40441c2dd159f600776af4316400396a24a6cea1660a
Contents?: true
Size: 697 Bytes
Versions: 6
Compression:
Stored size: 697 Bytes
Contents
require_relative "./letter_gen" module VGen class StringGen attr_reader :char_gen def initialize( char_gen: LetterGen.new, length: (4..9), except: [] ) @length = length @char_gen = char_gen @except = except end def call() loop do word = Array.new( word_length, @char_gen ).map(&:call).join return word unless @except.include? word end end private def word_length length = Random.new.rand(@length) if @length.is_a? Range length = @length if @length.is_a? Integer length end end end
Version data entries
6 entries across 4 versions & 2 rubygems