class Faker::Boolean

Public Class Methods

boolean(true_ratio: 0.5) click to toggle source

Produces a boolean

@param true_ratio [Float] The likelihood (as a float, out of 1.0) for the method to return ‘true`. @return [Boolean]

@example

Faker::Boolean.boolean #=> true

@example

Faker::Boolean.boolean(true_ratio: 0.2) #=> false

@faker.version 1.6.2

# File lib/faker/default/boolean.rb, line 18
def boolean(true_ratio: 0.5)
  (rand < true_ratio)
end