class RandomText::RandomStrings
Public Instance Methods
get(count = nil)
click to toggle source
# File lib/random_text/random_strings.rb, line 3 def get(count = nil) case count when :all to_a.sort_by{ Kernel.rand } when Integer Array.new(count){ rand } else rand end end
rand()
click to toggle source
# File lib/random_text/random_strings.rb, line 24 def rand self[Kernel.rand(length)] end
uniq(count)
click to toggle source
# File lib/random_text/random_strings.rb, line 14 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