Sha256: 5704e186c32e285cfd4154908364d67a3f7d9e49a7e1f80964cb1d4eeb220872
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module FFakerTW module NameDA include FFakerTW::Name extend ModuleUtils extend self PREFIXES = %w[Hr. Fr. Dr. Prof.].freeze def name(gender = :any) generate_name(first_name(gender)) end def any_name name(:any) end def male_name name(:male) end def female_name name(:female) end def first_name(gender = :any) case gender when :any then rand(0..1).zero? ? first_name(:male) : first_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 def last_name fetch_sample(LAST_NAMES) end def prefix fetch_sample(PREFIXES) end private def generate_name(first_name) case rand(0..7) 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffakerTW-0.1.0 | lib/ffakerTW/name_da.rb |