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 Faker::Gender.short_binary_type #1863

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/default/gender.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Available since version 1.9.0.
Faker::Gender.type #=> "Non-binary"

Faker::Gender.binary_type #=> "Female"

Faker::Gender.short_binary_type #=> "f"
```
13 changes: 13 additions & 0 deletions lib/faker/default/gender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ def type
def binary_type
fetch('gender.binary_types')
end

##
# Produces either 'f' or 'm'.
#
# @return [String]
#
# @example
# Faker::Gender.short_binary_type #=> "f"
#
# @faker.version next
def short_binary_type
fetch('gender.short_binary_types')
end
end
end
end
1 change: 1 addition & 0 deletions lib/locales/en/gender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ en:
gender:
types: ["Female", "Male", "Non-binary", "Agender", "Genderfluid", "Genderqueer", "Bigender", "Polygender"]
binary_types: ["Female", "Male"]
short_binary_types: ["f", "m"]
4 changes: 4 additions & 0 deletions test/faker/default/test_faker_gender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ def test_type
def test_binary_type
assert @tester.binary_type.match(/\w+/)
end

def test_short_binary_type
assert @tester.short_binary_type.match(/f|m/)
end
end