Sha256: e63cd526e3ea19bb715d22b648a5760e4e09eaa9af29f2d91cd318c7110499dd

Contents?: true

Size: 854 Bytes

Versions: 6

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

require "arraybuffer"
require "murmurhash3"

module Absmartly
  # VariantAssigner
  class VariantAssigner
    def initialize(_unit)
      # this._unitHash = murmur3_32(stringToUint8Array(unit).buffer);
    end

    def assign(split, seed_hi, seed_lo)
      prob = probability(seed_hi, seed_lo)
      chooseVariant(split, prob)
    end

    # private

    # def chooseVariant(split, prob)
    #
    # end
    #
    # def probability(seedHi, seedLo)
    #   const key = this._unitHash;
    #   const buffer = new ArrayBuffer(12)
    #   const view = new DataView(buffer)
    #   view.setUint32(0, seedLo, true)
    #   view.setUint32(4, seedHi, true)
    #   view.setUint32(8, key, true)
    #
    #   murmur3_32(buffer) * (1.0 / 0xffffffff)
    # end
  end
end
# DataView.new(new_bytes_buffer, src_offset, new_bytes.length)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
absmartly-sdk-1.1.0 lib/absmartly/variant_assigner.rb
absmartly-sdk-1.0.8 lib/absmartly/variant_assigner.rb
absmartly-sdk-1.0.7 lib/absmartly/variant_assigner.rb
absmartly-sdk-1.0.6 lib/absmartly/variant_assigner.rb
absmartly-sdk-1.0.5 lib/absmartly/variant_assigner.rb
absmartly-sdk-0.1.2 lib/absmartly/variant_assigner.rb