Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YARD docs for Faker::Name #1976

Merged
merged 3 commits into from May 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
83 changes: 83 additions & 0 deletions lib/faker/default/name.rb
Expand Up @@ -5,14 +5,41 @@ class Name < Base
flexible :name

class << self
##
# Produces a random name.
#
# @return [String]
#
# @example
# Faker::Name.name #=> "Tyshawn Johns Sr."
#
# @faker.version 0.9.0
def name
parse('name.name')
end

##
# Produces a random name with middle name.
#
# @return [String]
#
# @example
# Faker::Name.name_with_middle #=> "Aditya Elton Douglas"
#
# @faker.version 1.6.4
def name_with_middle
parse('name.name_with_middle')
end

##
# Produces a random first name.
#
# @return [String]
#
# @example
# Faker::Name.first_name #=> "Kaci"
#
# @faker.version 0.9.0
def first_name
if parse('name.first_name').empty?
fetch('name.first_name')
Expand All @@ -21,31 +48,87 @@ def first_name
end
end

##
# Produces a random male first name.
#
# @return [String]
#
# @example
# Faker::Name.male_first_name #=> "Edward"
#
# @faker.version 1.9.1
def male_first_name
fetch('name.male_first_name')
end
alias first_name_men male_first_name
alias masculine_name male_first_name

##
# Produces a random female first name.
#
# @return [String]
#
# @example
# Faker::Name.female_first_name #=> "Natasha"
#
# @faker.version 1.9.1
def female_first_name
fetch('name.female_first_name')
end
alias first_name_women female_first_name
alias feminine_name female_first_name

##
# Produces a random last name.
#
# @return [String]
#
# @example
# Faker::Name.last_name #=> "Ernser"
#
# @faker.version 0.9.0
def last_name
parse('name.last_name')
end
alias middle_name last_name

##
# Produces a random name prefix.
#
# @return [String]
#
# @example
# Faker::Name.prefix #=> "Mr."
#
# @faker.version 0.9.0
def prefix
fetch('name.prefix')
end

##
# Produces a random name suffix.
#
# @return [String]
#
# @example
# Faker::Name.suffix #=> "IV"
#
# @faker.version 0.9.0
def suffix
fetch('name.suffix')
end

##
# Produces random initials.
#
# @param digits [Integer] Number of digits that the generated initials should have.
# @return [String]
#
# @example
# Faker::Name.initials #=> "NJM"
# Faker::Name.initials(number: 2) #=> "NM"
#
# @faker.version 1.8.5
def initials(legacy_number = NOT_GIVEN, number: 3)
warn_for_deprecated_arguments do |keywords|
keywords << :number if legacy_number != NOT_GIVEN
Expand Down