Sha256: 179bfe2036941d6bf684e27e8f1e5b57d45f44ac090506cde2f2b87d26f1b5e0

Contents?: true

Size: 407 Bytes

Versions: 22

Compression:

Stored size: 407 Bytes

Contents

module Verdict
  module Segmenters
    class RandomPercentageSegmenter < FixedPercentageSegmenter

      attr_accessor :random

      def initialize(*args)
        super
        @random = Random.new
      end

      def assign(identifier, subject, context)
        percentile = @random.rand(100)
        groups.values.find { |group| group.percentile_range.include?(percentile) }
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
verdict-0.3.2 lib/verdict/segmenters/random_percentage_segmenter.rb
verdict-0.3.1 lib/verdict/segmenters/random_percentage_segmenter.rb