Sha256: 12224f8ba29e7eb27b797c69b7bc840fc6a2f0e1ad0a252b832e7f7648f9612a
Contents?: true
Size: 428 Bytes
Versions: 4
Compression:
Stored size: 428 Bytes
Contents
require 'rubyonacid/factory' module RubyOnAcid class SkipFactory < Factory #The percentage odds that the factory will return 0 instead of 1. attr_accessor :odds def initialize(odds = 0.1) super @odds = odds end #If a random number between 0 and 1 is less than the assigned odds value, will return 0 (a "skip"). #Otherwise returns 1. def get_unit(key) rand < @odds ? 0.0 : 1.0 end end end
Version data entries
4 entries across 4 versions & 1 rubygems