Module: FFaker::NameMX

Extended by:
ModuleUtils, NameMX
Includes:
Name
Included in:
NameMX
Defined in:
lib/ffaker/name_mx.rb

Overview

guapolo github.com/guapolo

Constant Summary collapse

MALE_PREFIXES =
%w[Sr. C.].freeze
FEMALE_PREFIXES =
%w[Sra. Srita. C.].freeze
PREFIXES =
%w[Sr. Sra. Srita. C.].freeze

Constants included from Name

FFaker::Name::FIRST_NAMES, FFaker::Name::OTHER_PREFIXES, FFaker::Name::SUFFIXES

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Methods included from Name

#female_name_with_prefix, #female_name_with_prefix_suffix, #female_name_with_suffix, #first_name_female, #first_name_male, #html_safe_last_name, #html_safe_name, #male_name_with_prefix, #male_name_with_prefix_suffix, #male_name_with_suffix, #name_with_prefix, #name_with_prefix_suffix, #name_with_suffix, #other_prefix, #pronouns, #suffix

Instance Method Details

#female_nameObject

Female first name and possibly middle name


61
62
63
64
65
66
# File 'lib/ffaker/name_mx.rb', line 61

def female_name
  case rand(0..8)
  when 0, 5 then "#{first_name(:female)} #{middle_name(:female)}"
  else first_name(:female)
  end
end

#female_prefixObject


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

def female_prefix
  fetch_sample(FEMALE_PREFIXES)
end

#full_name(gender = :any, prefix = false) ⇒ Object

Full name according to gender and prefix, possibly with middle_name


16
17
18
19
20
21
22
# File 'lib/ffaker/name_mx.rb', line 16

def full_name(gender = :any, prefix = false)
  if prefix
    full_name_prefix(gender)
  else
    full_name_no_prefix(gender)
  end
end

#full_name_no_prefix(gender = :any) ⇒ Object

Full name with no prefix according to gender, possibly with middle_name


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ffaker/name_mx.rb', line 39

def full_name_no_prefix(gender = :any)
  case gender
  when :any
    case rand(0..8)
    when 0, 3, 6, 8 then "#{female_name} #{paternal_last_names}"
    else "#{male_name} #{paternal_last_names}"
    end
  when :male then "#{male_name} #{paternal_last_names}"
  when :female then "#{female_name} #{paternal_last_names}"
  else raise ArgumentError, 'Invalid gender, must be one of :any, :male, :female'
  end
end

#full_name_prefix(gender = :any) ⇒ Object

Full name with prefix according to gender, possibly with middle_name


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ffaker/name_mx.rb', line 25

def full_name_prefix(gender = :any)
  case gender
  when :any
    case rand(0..8)
    when 0, 3, 6, 8 then "#{female_prefix} #{female_name} #{paternal_last_names}"
    else "#{male_prefix} #{male_name} #{paternal_last_names}"
    end
  when :male then "#{male_prefix} #{male_name} #{paternal_last_names}"
  when :female then "#{female_prefix} #{female_name} #{paternal_last_names}"
  else raise ArgumentError, 'Invalid gender, must be one of :any, :male, :female'
  end
end

#last_nameObject


85
86
87
# File 'lib/ffaker/name_mx.rb', line 85

def last_name
  fetch_sample(LAST_NAMES)
end

#male_nameObject

Male first name and possibly middle name


53
54
55
56
57
58
# File 'lib/ffaker/name_mx.rb', line 53

def male_name
  case rand(0..8)
  when 0, 5 then "#{first_name(:male)} #{middle_name(:male)}"
  else first_name(:male)
  end
end

#male_prefixObject


93
94
95
# File 'lib/ffaker/name_mx.rb', line 93

def male_prefix
  fetch_sample(MALE_PREFIXES)
end

#name(gender = :any) ⇒ Object Also known as: middle_name, first_name

A single name according to gender parameter


69
70
71
72
73
74
75
76
# File 'lib/ffaker/name_mx.rb', line 69

def name(gender = :any)
  case gender
  when :any then rand(0..1).zero? ? name(:male) : name(:female)
  when :male then fetch_sample(MALE_FIRST_NAMES)
  when :female then fetch_sample(FEMALE_FIRST_NAMES)
  else raise ArgumentError, 'Invalid gender, must be one of :any, :male, :female'
  end
end

#paternal_last_namesObject

Father's and mother's last name


81
82
83
# File 'lib/ffaker/name_mx.rb', line 81

def paternal_last_names
  "#{last_name} #{last_name}"
end

#prefixObject


89
90
91
# File 'lib/ffaker/name_mx.rb', line 89

def prefix
  fetch_sample(PREFIXES)
end