Mega Code Archive

 
Categories / Ruby / Development
 

Generate random numbers

def random_word  letters = { ?v => 'aeiou',              ?c => 'bcdfghjklmnprstvwyz' }   word = ''   'cvcvcvc'.each_byte do |x|     source = letters[x]     word << source[rand(source.length)].chr   end   return word end puts random_word                         # => "josuyip" puts random_word                         # => "haramic"