Module: FFaker::Name

Extended by:
ModuleUtils, Name
Included in:
Name, NameCS, NameDA, NameDE, NameMX, NameNB, NameNL, NamePH, NameSE
Defined in:
lib/ffaker/name.rb

Constant Summary collapse

MALE_PREFIXES =
%w[Mr.].freeze
FEMALE_PREFIXES =
%w[Mrs. Miss.].freeze
OTHER_PREFIXES =
%w[Ms. Dr.].freeze
PREFIXES =
(MALE_PREFIXES + FEMALE_PREFIXES + OTHER_PREFIXES).freeze
FIRST_NAMES =
(FIRST_NAMES_FEMALE + FIRST_NAMES_MALE).freeze
SUFFIXES =
%w[Jr. Sr. I II III IV V MD DDS PhD DVM].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#female_name_with_prefixObject


50
51
52
# File 'lib/ffaker/name.rb', line 50

def female_name_with_prefix
  "#{female_prefix} #{first_name_female} #{last_name}"
end

#female_name_with_prefix_suffixObject


66
67
68
# File 'lib/ffaker/name.rb', line 66

def female_name_with_prefix_suffix
  "#{female_prefix} #{first_name_female} #{last_name} #{suffix}"
end

#female_name_with_suffixObject


58
59
60
# File 'lib/ffaker/name.rb', line 58

def female_name_with_suffix
  "#{first_name_female} #{last_name} #{suffix}"
end

#female_prefixObject


101
102
103
# File 'lib/ffaker/name.rb', line 101

def female_prefix
  fetch_sample(FEMALE_PREFIXES)
end

#first_nameObject


74
75
76
# File 'lib/ffaker/name.rb', line 74

def first_name
  fetch_sample(FIRST_NAMES)
end

#first_name_femaleObject


78
79
80
# File 'lib/ffaker/name.rb', line 78

def first_name_female
  fetch_sample(FIRST_NAMES_FEMALE)
end

#first_name_maleObject


82
83
84
# File 'lib/ffaker/name.rb', line 82

def first_name_male
  fetch_sample(FIRST_NAMES_MALE)
end

#html_safe_last_nameObject


90
91
92
93
94
95
# File 'lib/ffaker/name.rb', line 90

def html_safe_last_name
  loop do
    t = LAST_NAMES.sample
    return t unless t.include? "'"
  end
end

#html_safe_nameObject


19
20
21
# File 'lib/ffaker/name.rb', line 19

def html_safe_name
  "#{first_name} #{html_safe_last_name}"
end

#last_nameObject


86
87
88
# File 'lib/ffaker/name.rb', line 86

def last_name
  fetch_sample(LAST_NAMES)
end

#male_name_with_prefixObject


54
55
56
# File 'lib/ffaker/name.rb', line 54

def male_name_with_prefix
  "#{male_prefix} #{first_name_male} #{last_name}"
end

#male_name_with_prefix_suffixObject


70
71
72
# File 'lib/ffaker/name.rb', line 70

def male_name_with_prefix_suffix
  "#{male_prefix} #{first_name_male} #{last_name} #{suffix}"
end

#male_name_with_suffixObject


62
63
64
# File 'lib/ffaker/name.rb', line 62

def male_name_with_suffix
  "#{first_name_male} #{last_name} #{suffix}"
end

#male_prefixObject


105
106
107
# File 'lib/ffaker/name.rb', line 105

def male_prefix
  fetch_sample(MALE_PREFIXES)
end

#nameObject


15
16
17
# File 'lib/ffaker/name.rb', line 15

def name
  "#{first_name} #{last_name}"
end

#name_with_prefixObject


23
24
25
26
27
28
29
30
# File 'lib/ffaker/name.rb', line 23

def name_with_prefix
  fetch_sample(
    [
      female_name_with_prefix,
      male_name_with_prefix
    ]
  )
end

#name_with_prefix_suffixObject


41
42
43
44
45
46
47
48
# File 'lib/ffaker/name.rb', line 41

def name_with_prefix_suffix
  fetch_sample(
    [
      female_name_with_prefix_suffix,
      male_name_with_prefix_suffix
    ]
  )
end

#name_with_suffixObject


32
33
34
35
36
37
38
39
# File 'lib/ffaker/name.rb', line 32

def name_with_suffix
  fetch_sample(
    [
      female_name_with_suffix,
      male_name_with_suffix
    ]
  )
end

#other_prefixObject


109
110
111
# File 'lib/ffaker/name.rb', line 109

def other_prefix
  fetch_sample(OTHER_PREFIXES)
end

#prefixObject


97
98
99
# File 'lib/ffaker/name.rb', line 97

def prefix
  fetch_sample(PREFIXES)
end

#suffixObject


113
114
115
# File 'lib/ffaker/name.rb', line 113

def suffix
  fetch_sample(SUFFIXES)
end