module Faker::NameRU

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)
  FIRST_NAMES[select_sex(for_sex)].rand
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)
  LAST_NAMES[select_sex(for_sex)].rand
end

def name(for_sex = :random)

for_sex defaults to :random.

Faker::NameRU.name(:male)

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

def patronymic(for_sex = :random)

for_sex can be :male, :female. Defaults to :random
Generates random patronymic
def patronymic(for_sex = :random)
  PATRONYMICS[select_sex(for_sex)].rand
end

def select_sex(sex) # :nodoc:

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

def with_same_sex(sex = :random)

person.patronymic # => "Петрович"
person.first_name # => "Александр"
person.last_name # => "Иванов"

end
person.patronymic = Faker::NameRU.patronymic
person.first_name = Faker::NameRU.first_name
person.last_name = Faker::NameRU.last_name
Faker::NameRU.with_same_sex(:male)

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(2)] : sex
  yield
ensure
  @fixed_sex = nil
end