Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create email address generator with Ruby?

  def emails
    i = 0
    number = rand(252...4350)

    males = ["tom", "jack", "adam"]
    females = ["elizabeth", "rose", "juliet"]

    surnameMales = ["oak", "yew", "timber"]
    surnameFemales = ["rosewelth", "gates", "jobs"]

    providers = ["gmail.com", "hotmail.com", "yahoo.com"]

    while i <= 100 do
      @addresses << 
    end
  end

What I want to do is pick a random number, name, surname and provider and put them all together + attach a random number at the end of the surname so that it looks, for example, like this: [email protected], but kind of got stuck at the point where I have to put the whole thing together. As you can probably tell, I want to create a 100 random emails for testing purposes.

Can you please point me out how I could do what I have intended to do with Ruby?

like image 971
Xeen Avatar asked Sep 12 '26 12:09

Xeen


1 Answers

Is your goal to do this as an exercise or is this just something you're trying to get done? If it's the latter, install the faker gem and just use it:

Faker::Internet.email #=> "[email protected]"

For 100:

100.times.map { Faker::Internet.email }
like image 154
Nick Veys Avatar answered Sep 14 '26 03:09

Nick Veys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!