Skip to content

Instantly share code, notes, and snippets.

@jashmenn

jashmenn/gist:16738

Created Oct 14, 2008
Embed
What would you like to do?
random-pronounceable-strings-in-ruby
#!/usr/bin/env ruby
# from http://e-huned.com/2008/10/13/random-pronounceable-strings-in-ruby/
require 'rubygems'
require 'activesupport'
class String
def self.random_pronounceable(syllables = 2)
alphabet = ('a'..'z').to_a
vowels = %w{ a e i o u }
consonants = alphabet - vowels
returning Array.new do |r|
syllables.times do
r << consonants.rand
r << vowels.rand
r << alphabet.rand
end
r << rand(1000)
end.join
end
end
how_long = ARGV[0].to_i > 0 ? ARGV[0].to_i : 2
puts String.random_pronounceable(how_long)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.