Class: Contracts::Builtin::Maybe

Inherits:
Object
  • Object
show all
Defined in:
lib/contracts/builtin_ext.rb

Instance Method Summary collapse

Instance Method Details

#generate(nil_ratio: 0.5) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/contracts/builtin_ext.rb', line 70

def generate(nil_ratio: 0.5)
  if Bool.generate(true_ratio: nil_ratio)
    @vals.reject(&:nil?).first.generate
  else
    nil
  end
end