Class: Synthra::Types::PersonalNames::Gender
- Defined in:
- lib/synthra/types/personal_names/identifiers.rb
Overview
Gender type
Constant Summary collapse
- GENDERS =
Available gender identity values
["male", "female", "non-binary", "other", "prefer not to say"].freeze
Instance Method Summary collapse
- #generate_edge(rng, context, args) ⇒ Object
- #generate_invalid(rng, context, args) ⇒ Object
-
#generate_random(rng, context, args) ⇒ String
Generate random gender.
Instance Method Details
#generate_edge(rng, context, args) ⇒ Object
124 125 126 |
# File 'lib/synthra/types/personal_names/identifiers.rb', line 124 def generate_edge(rng, context, args) ["", "male", "female"].sample(random: rng.instance_variable_get(:@random)) end |
#generate_invalid(rng, context, args) ⇒ Object
128 129 130 |
# File 'lib/synthra/types/personal_names/identifiers.rb', line 128 def generate_invalid(rng, context, args) [nil, 123, [], {}].sample(random: rng.instance_variable_get(:@random)) end |
#generate_random(rng, context, args) ⇒ String
Generate random gender
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/synthra/types/personal_names/identifiers.rb', line 97 def generate_random(rng, context, args) format_type = args[:format] || :short # Try Faker first adapter = faker_adapter(context) if adapter gender = adapter.gender else gender = Faker::Gender.type end case format_type when :capitalized gender.to_s.capitalize when :full gender.to_s else gender.to_s[0..2] # Short format end rescue StandardError rng.sample(GENDERS) # fallback end |