@Zavexeon/

Name Generator v.2

Ruby

No description

fork
loading
Files
  • main.rb
  • lastnames.txt
  • masterfirstnames.txt
  • middlenames.txt
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
first_names = File.foreach('masterfirstnames.txt').map { |line| line.split(' ') }
last_names = File.foreach('lastnames.txt').map { |line| line.split(' ') }
middle_names = File.foreach('middlenames.txt').map { |line| line.split(' ') }

puts "(C)2018 Zavexeon"

puts "\nNotes: Generating over 50,000 names will lead to performance issues, so it will be slowed. There is some lag with displaying large results to the console, times may seem innacurate because of this. These times are correct. Names identical to those living is purely coincidential, or are they?

Press \"Enter\" to continue.
"
gets.chomp

html = ""
slashhtml = ""
ol = ""
slashol = ""
slashul = ""
counter = 0
loop do
  print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nHow many names would you like to generate:"
  number = gets.chomp.to_i
  print "HTML list formatting? Y/N:"
  formatting = gets.chomp.downcase
  if formatting.include?("y")
  	html = "<li>"
  	slashhtml = "</li>"
  	ol = "<ul>"
  	slashol = "</ul>"
  else  
  	html = ""
	slashhtml = ""
	ol = ""
	slashol = ""
	slashul = ""
  end 
  if number > 0
    puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
    puts "Generating #{number} names...\n\n#{ol}"
    t1 = Time.now
    number.times do
      if number >= 10000
        sleep(0.05)
      end
      counter += 1
      firstname = first_names.sample.to_s
      lastname = last_names.sample.to_s
      middlename = middle_names.sample.to_s
      firstname = firstname.gsub("[", "")
      firstname = firstname.gsub("]", "")
      firstname = firstname.gsub("\"", "")
      firstname = firstname.capitalize
      lastname = lastname.gsub("[", "")
      lastname = lastname.gsub("]", "")
      lastname = lastname.gsub("\"", "")
      lastname = lastname.capitalize
      middlename = middle_names.sample.to_s
      middlename = middlename.gsub("[", "")
      middlename = middlename.gsub("]", "")
      middlename = middlename.gsub("\"", "")
      middlename = middlename.capitalize
      puts "#{html}#{counter}.)#{firstname} #{middlename} #{lastname}#{slashhtml}"
    end
    puts "#{slashol}"
    if counter == 666 
    	delta = 0.666
    end 
    t2 = Time.now
    delta = t2 - t1
    puts "\nSuccesfully generated #{counter} names in #{delta.round(2)} second(s)"
    puts "\nPress \"Enter\" to generate more names."
    gets.chomp
    counter = 0
    else 
    puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nInvalid input. Please enter number greater than zero.
Press \"Enter\" to continue."
    gets.chomp
  end
end
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]