Sha256: 12c368db7a571607854a4db185d5f676b0c0b7a3bc7380a781ebc5a886682c87

Contents?: true

Size: 534 Bytes

Versions: 12

Compression:

Stored size: 534 Bytes

Contents

# frozen_string_literal: true

module Faker
  class Boolean < Base
    class << self
      ##
      # 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
      def boolean(true_ratio: 0.5)
        (rand < true_ratio)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
faker-3.5.1 lib/faker/default/boolean.rb
faker-3.4.2 lib/faker/default/boolean.rb
faker-3.4.1 lib/faker/default/boolean.rb
faker-3.3.1 lib/faker/default/boolean.rb
faker-3.3.0 lib/faker/default/boolean.rb
faker-3.2.3 lib/faker/default/boolean.rb
faker-3.2.2 lib/faker/default/boolean.rb
faker-3.2.1 lib/faker/default/boolean.rb
faker-3.2.0 lib/faker/default/boolean.rb
faker-3.1.1 lib/faker/default/boolean.rb
faker-3.1.0 lib/faker/default/boolean.rb
faker-3.0.0 lib/faker/default/boolean.rb