module FFaker::NameCS

def first_name(for_sex = :random)

for_sex can be :male, :female. Defaults to :random
Generates random first name
def first_name(for_sex = :random)
  fetch_sample(FIRST_NAMES[select_sex(for_sex)])
end

def last_name(for_sex = :random)

for_sex can be :male, :female. Defaults to :random
Generates random last name
def last_name(for_sex = :random)
  fetch_sample(LAST_NAMES[select_sex(for_sex)])
end

def name(for_sex = :random)

for_sex defaults to :random.

FFaker::NameCS.name(:male)

Can be called with explicit sex (:male, :female), like:
Generates random full name which can contain prefix and suffix
def name(for_sex = :random)
  with_same_sex(for_sex) do
    case rand(0..9)
    when 0     then "#{prefix} #{first_name} #{last_name} #{suffix}"
    when 1..2  then "#{prefix} #{first_name} #{last_name}"
    else "#{first_name} #{last_name}"
    end
  end
end

def prefix

Generates random name prefix, an academic degree
def prefix
  fetch_sample(PREFIXES)
end

def select_sex(sex) # :nodoc:

:nodoc:
def select_sex(sex) # :nodoc:
  @fixed_sex ||= nil
  given_sex = @fixed_sex || sex
  raise ArgumentError, "Unknown sex #{given_sex}" unless GENDERS.include?(given_sex)
  given_sex == :random ? GENDERS[rand(0..1)] : given_sex
end

def suffix

Generates random name suffix, an academic degree
def suffix
  fetch_sample(SUFFIXES)
end

def with_same_sex(sex = :random)

person.first_name # => "Jana"
person.last_name # => "Nováková"

end
person.first_name = FFaker::NameCS.first_name
person.last_name = FFaker::NameCS.last_name
FFaker::NameCS.with_same_sex(:female)

all calls inside thee block:
Can be called with explicit sex which will affect
All names generated inside the block will have the same sex.
def with_same_sex(sex = :random)
  @fixed_sex = sex == :random ? GENDERS[rand(0..1)] : sex
  yield
ensure
  @fixed_sex = nil
end