class Randrizer::Types::Bool
A boolean type. Can be either `true` or `false`.
Constants
- PRESENCE_MAYBE
Public Class Methods
new(true_prob: PRESENCE_MAYBE)
click to toggle source
# File lib/randrizer/types/bool.rb, line 11 def initialize(true_prob: PRESENCE_MAYBE) @true_prob = true_prob end
Public Instance Methods
eval()
click to toggle source
# File lib/randrizer/types/bool.rb, line 20 def eval rand > (1.0 - @true_prob) end
validate!()
click to toggle source
# File lib/randrizer/types/bool.rb, line 15 def validate! raise ValidationError("true_prob must be < 1.0") if @true_prob > 1.0 raise ValidationError("true_prob must be > 0.0") if @true_prob < 0.0 end