Module: Faker::NameDA

Extended by:
ModuleUtils, NameDA
Includes:
Name
Included in:
NameDA
Defined in:
lib/ffakerer/name_da.rb

Constant Summary collapse

PREFIXES =
k %w(Hr. Fr. Dr. Prof.)

Constants included from Name

Faker::Name::SUFFIXES

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Methods included from Name

#suffix

Instance Method Details

#any_nameObject



22
23
24
25
26
27
28
# File 'lib/ffakerer/name_da.rb', line 22

def any_name
  case rand(8)
  when 0    then "#{prefix} #{first_name} #{last_name}"
  when 1..2 then "#{first_name} #{last_name} #{last_name}"
  else           "#{first_name} #{last_name}"
  end
end

#female_nameObject



39
40
41
42
43
44
45
46
# File 'lib/ffakerer/name_da.rb', line 39

def female_name
  fname = first_name :female
  case rand(8)
  when 0    then "#{prefix} #{fname} #{last_name}"
  when 1..2 then "#{fname} #{last_name} #{last_name}"
  else           "#{fname} #{last_name}"
  end
end

#first_name(gender = :any) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/ffakerer/name_da.rb', line 48

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

#last_nameObject



58
59
60
# File 'lib/ffakerer/name_da.rb', line 58

def last_name
  LAST_NAMES.rand
end

#male_nameObject



30
31
32
33
34
35
36
37
# File 'lib/ffakerer/name_da.rb', line 30

def male_name
  fname = first_name :male
  case rand(8)
  when 0    then "#{prefix} #{fname} #{last_name}"
  when 1..2 then "#{fname} #{last_name} #{last_name}"
  else           "#{fname} #{last_name}"
  end
end

#name(gender = :any) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/ffakerer/name_da.rb', line 12

def name gender = :any
  case gender
  when :any then any_name
  when :male then male_name
  when :female then female_name
  else
    raise ArgumentError, "Invalid gender, must be one of :any, :male, :female"
  end
end

#prefixObject



62
63
64
# File 'lib/ffakerer/name_da.rb', line 62

def prefix
  PREFIXES.rand
end