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.)
FEMALE_PREFIXES =
%w(Sra. Srita. C.)
PREFIXES =
%w(Sr. Sra. Srita. C.)

Constants included from Name

FFaker::Name::SUFFIXES

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Methods included from Name

#suffix

Instance Method Details

#female_nameObject

Female first name and possibly middle name


63
64
65
66
67
68
# File 'lib/ffaker/name_mx.rb', line 63

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

#female_prefixObject


99
100
101
# File 'lib/ffaker/name_mx.rb', line 99

def female_prefix
  FEMALE_PREFIXES.sample
end

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

Full name according to gender and prefix, possibly with middle_name


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

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


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

def full_name_no_prefix(gender = :any)
  case gender
  when :any then
    case rand(9)
    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 fail 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


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

def full_name_prefix(gender = :any)
  case gender
  when :any then
    case rand(9)
    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 fail ArgumentError, 'Invalid gender, must be one of :any, :male, :female'
  end
end

#last_nameObject


87
88
89
# File 'lib/ffaker/name_mx.rb', line 87

def last_name
  LAST_NAMES.sample
end

#male_nameObject

Male first name and possibly middle name


55
56
57
58
59
60
# File 'lib/ffaker/name_mx.rb', line 55

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

#male_prefixObject


95
96
97
# File 'lib/ffaker/name_mx.rb', line 95

def male_prefix
  MALE_PREFIXES.sample
end

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

A single name according to gender parameter


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

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

#paternal_last_namesObject

Father's and mother's last name


83
84
85
# File 'lib/ffaker/name_mx.rb', line 83

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

#prefixObject


91
92
93
# File 'lib/ffaker/name_mx.rb', line 91

def prefix
  PREFIXES.sample
end