Skip to content

Instantly share code, notes, and snippets.

@kenn
Created February 7, 2013 03:53
Show Gist options
  • Save kenn/4728296 to your computer and use it in GitHub Desktop.
Save kenn/4728296 to your computer and use it in GitHub Desktop.
require 'securerandom'
module Syllable
CONSONANT = %w(b c d f g h j k l m n p qu r s t v w x z ch cr fr nd ng nk nt ph pr rd sh sl sp st th tr lt)
VOWEL = %w(a e i o u y)
def generate(size=2)
"".tap do |result|
(size * 2).times do |i|
result << (i.even? ? CONSONANT[SecureRandom.random_number * CONSONANT.size] : VOWEL[SecureRandom.random_number * VOWEL.size])
end
end
end
module_function :generate
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment