Functions for generating random boolean values.
Provides utilities to generate true or false with a configurable probability,
with an option to return integer equivalents instead.
Summary
Functions
Generates a random boolean value with a configurable probability of returning true.
Functions
@spec boolean(0..100, Keyword.t()) :: boolean() | non_neg_integer()
Generates a random boolean value with a configurable probability of returning true.
The true_ratio parameter sets the percentage chance (0–100) of returning true.
Pass integer: true to receive 1 or 0 instead of true or false.
Parameters
true_ratio- Percentage probability of returningtrue(0–100). Defaults to50.opts- Keyword list of options::integer- Whentrue, returns1or0. Defaults tofalse.
Examples
iex> NeoFaker.Boolean.boolean()
false
iex> NeoFaker.Boolean.boolean(75)
true
iex> NeoFaker.Boolean.boolean(75, integer: true)
1
iex> NeoFaker.Boolean.boolean(0)
false
iex> NeoFaker.Boolean.boolean(100)
true