File: name_ua.rb

package info (click to toggle)
ruby-ffaker 2.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,776 kB
  • sloc: ruby: 12,788; makefile: 8; sh: 1
file content (57 lines) | stat: -rw-r--r-- 1,354 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true

module FFaker
  module NameUA
    extend ModuleUtils
    extend self

    FIRST_NAMES  = FIRST_NAMES_MALE + FIRST_NAMES_FEMALE
    LAST_NAMES   = LAST_NAMES_MALE + LAST_NAMES_FEMALE
    MIDDLE_NAMES = MIDDLE_NAMES_MALE + MIDDLE_NAMES_FEMALE

    def first_name_female
      fetch_sample(FIRST_NAMES_FEMALE)
    end

    def first_name_male
      fetch_sample(FIRST_NAMES_MALE)
    end

    def middle_name_female
      fetch_sample(MIDDLE_NAMES_FEMALE)
    end

    def middle_name_male
      fetch_sample(MIDDLE_NAMES_MALE)
    end

    def last_name_female
      fetch_sample(LAST_NAMES_FEMALE)
    end

    def last_name_male
      fetch_sample(LAST_NAMES_MALE)
    end

    def first_name
      fetch_sample(FIRST_NAMES)
    end

    def last_name
      fetch_sample(LAST_NAMES)
    end

    def name
      case rand(0..7)
      when 0 then first_name_male
      when 1 then first_name_female
      when 2 then "#{first_name_male} #{middle_name_male}"
      when 3 then "#{first_name_female} #{middle_name_male}"
      when 4 then "#{last_name_male} #{first_name_male}"
      when 5 then "#{last_name_female} #{first_name_female}"
      when 6 then "#{last_name_male} #{first_name_male} #{middle_name_male}"
      when 7 then "#{last_name_female} #{first_name_female} #{middle_name_female}"
      end
    end
  end
end