Sha256: bbda144bc3952b14b077cb218a19f718f8db695fbf047d3009ef4ab0cf078aca
Contents?: true
Size: 533 Bytes
Versions: 1
Compression:
Stored size: 533 Bytes
Contents
class RandomText class RandomStrings < Array def get(count = nil) case count when :all to_a.sort_by{ Kernel.rand } when Integer Array.new(count){ rand } else rand end end def uniq(count) case count when :all get(:all) when Integer raise "Dictionary has only #{length} elements (you asked for n)" if count > length get(:all).slice(0, count) end end def rand self[Kernel.rand(length)] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
random_text-1.0.0 | lib/random_text/random_strings.rb |