Skip to content

Commit

Permalink
Add Faker::Gender.short_binary_type (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-b-martins authored and vbrazo committed Dec 16, 2019
1 parent db53ce5 commit 3670643
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
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

0 comments on commit 3670643

Please sign in to comment.