module RandomName VOWELS = %w/a e i o u/ CONSONANTS = ('a'..'z').to_a - RandomName::VOWELS LOCATIONS = %w/City Town County/ STREETS = %w/St Blvd Ave/ ORGANIZATIONS = %w/Committee Alliance Group/ SOCCER_CLUBS = LOCATIONS + (%w/United Athletic FC FC FC/ * 3) class << self def generate(num_syllables = 2) raise "Invalid number of syllables" unless (num_syllables.is_a?(Numeric) and num_syllables > 0) name = Array.new(num_syllables + 1){random_pick(CONSONANTS)}.join("@").gsub('@'){random_pick(VOWELS)} to_proper_name_case(name) end def generateStreet(num_syllables = 2) "#{generate(num_syllables)} #{random_pick(STREETS)}" end def generateLocation(num_syllables = 2) "#{generate(num_syllables)} #{random_pick(LOCATIONS)}" end def generateOrganization(num_syllables = 2) "#{generate(num_syllables)} #{random_pick(ORGANIZATIONS)}" end # FC stands for "Soccer Club" def generateFC(num_syllables = 2) "#{generate(num_syllables)} #{random_pick(SOCCER_CLUBS)}" end private def random_pick(array) array[rand(array.length)] end def to_proper_name_case (str) first, rest = str.split('', 2) first.upcase + rest.downcase end end end