Module: Randomly

Defined in:
lib/version.rb,
lib/randomly.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.generate(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/randomly.rb', line 3

def self.generate(options = {})
  options = {
    :length => 8, 
    :chars => ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
  }.merge!(options)
  
  Array.new(options[:length]) { options[:chars].to_a[rand(options[:chars].to_a.size)] }.join
end