Methods to create realistic-looking names
Returns a random company name
>> Random.company_name
“Harris & Thomas”
# File lib/random_data/names.rb, line 26 def companyname num = rand(5) if num == 0 num = 1 end final = num.times.collect { @@lastnames.rand.capitalize } if final.count == 1 "#{final.first} #{@@company_types.rand}, #{@@incorporation_types.rand}" else incorporation_type = rand(17) % 2 == 0 ? @@incorporation_types.rand : nil company_type = rand(17) % 2 == 0 ? @@company_types.rand : nil trailer = company_type.nil? ? "" : " #{company_type}" trailer << ", #{incorporation_type}" unless incorporation_type.nil? "#{final[0..-1].join(', ')} & #{final.last}#{trailer}" end end
Returns a random firstname
>> Random.firstname
“Sandra”
# File lib/random_data/names.rb, line 74 def firstname @@first_names.rand.capitalize end
Returns a random female firstname
>> Random.firstname_female
“Mary”
# File lib/random_data/names.rb, line 98 def firstname_female @@female_first_names.rand.capitalize end
Returns a random male firstname
>> Random.firstname_male
“James”
# File lib/random_data/names.rb, line 86 def firstname_male @@male_first_names.rand.capitalize end
Returns a random full name
# File lib/random_data/names.rb, line 104 def full_name(options = { :initial => false, :gender => nil }) "#{first_name} #{last_name}" end
Returns a random letter
# File lib/random_data/names.rb, line 8 def initial ('A'..'Z').to_a.rand end
Returns a random lastname
>> Random.lastname
“Harris”
# File lib/random_data/names.rb, line 51 def lastname @@lastnames.rand.capitalize end