Module: Gemmy::Patches::ObjectPatch::InstanceMethods::Maybe

Defined in:
lib/gemmy/patches/object_patch.rb

Instance Method Summary collapse

Instance Method Details

#maybe(chance = 0.5, &block) ⇒ Object

Random generator that returns true or false. Can also take a block that has a 50/50 chance to being executed… facets



111
112
113
114
115
116
117
# File 'lib/gemmy/patches/object_patch.rb', line 111

def maybe(chance = 0.5, &block)
  if block
    yield if rand < chance
  else
    rand < chance
  end
end