Class: FeatureHub::Sdk::Impl::Murmur3PercentageCalculator

Inherits:
PercentageCalculator show all
Defined in:
lib/feature_hub/sdk/impl/murmur3_percentage.rb

Overview

consistent across all platforms murmur percentage calculator

Constant Summary collapse

MAX_PERCENTAGE =
1_000_000
SEED =
0

Instance Method Summary collapse

Instance Method Details

#determine_client_percentage(percentage_text, feature_id) ⇒ Object



13
14
15
16
# File 'lib/feature_hub/sdk/impl/murmur3_percentage.rb', line 13

def determine_client_percentage(percentage_text, feature_id)
  result = MurmurHash3::V32.str_digest(percentage_text + feature_id, SEED).unpack1("L").to_f
  (result / (2**32) * MAX_PERCENTAGE).floor
end