Last active
August 29, 2015 14:02
-
-
Save bhardin/29bdfb305c9cef49e0a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def group(cookies) | |
return @group if @group | |
current_set = set_size | |
i = 0 | |
until @group | |
if seed <= current_set | |
@group = groups[i] | |
else | |
i += 1 | |
current_set += set_size | |
end | |
end | |
@group | |
end | |
def set_size | |
(1 / @groups.length.to_f) | |
end | |
def seed | |
return @seed if @seed | |
srand sha | |
@seed = rand | |
end | |
def sha | |
@sha ||= Digest::SHA1.hexdigest(test_name + ab_cookie_value.to_s).to_i(16) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment