class Name 
  def generate
    name = Array.new(rand(2..12))
    charVowels = ["a", "e", "i", "o", "u", "y"]
    charConsonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z"]
    
    charFirst = rand(0..1)
    if charFirst == 0
      name[0] = charVowels[rand(charVowels.length)]
    else
      name[0] = charConsonants[rand(charConsonants.length)]
    end

    (1..name.length-1).each do |index|
      if charVowels.include?(name[index-1])
        charNext = rand(0..1)
        if charNext == 0 && charConsonants.include?(name[index-2])
          name[index] = charVowels[rand(charVowels.length)]
        else
          name[index] = charConsonants[rand(charConsonants.length)]
        end
      else
        name[index] = name[index] = charVowels[rand(charVowels.length)]
      end
    end
    
    puts name.join("").capitalize
  end

end

newName = Name.new

newName.generate

class Name 
  def generate
    puts nameString
  end

  private

  $charVowels = ["a", "e", "i", "o", "u", "y"]
  $charConsonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z"]

  def nameString
    name = Array.new(rand(2..12))
    charFirst = rand(0..1)
    if charFirst == 0
      name[0] = randVowels 
    else
      name[0] = randConsonants 
    end
    (1..name.length-1).each do |index|
      if $charVowels.include?(name[index-1])
        charNext = rand(0..1)
        if charNext == 0 && $charConsonants.include?(name[index-2])
          name[index] = randVowels 
        else
          name[index] = randConsonants 
        end
      else
        name[index] = randVowels 
      end
    end
    name.join("").capitalize
  end

  def randVowels
    $charVowels[rand($charVowels.length)]  
  end

  def randConsonants
    $charConsonants[rand($charConsonants.length)]  
  end
end

newName = Name.new

newName.generate

Move randoms into defs and all defs inside private. TODO: remove $
Move randoms into defs and all defs inside private. TODO: remove $
