Sha256: 8661085bf74b3d0cd18aa0e1060a3e32d45cc06521ab74ebe5e4528ed3b142e6

Contents?: true

Size: 779 Bytes

Versions: 31

Compression:

Stored size: 779 Bytes

Contents

module Determinator
  class TargetGroup
    attr_reader :rollout, :constraints

    def initialize(rollout:, constraints: {})
      @rollout = rollout
      @constraints = constraints
    end

    def rollout_percent
      # Rollout is out of 65536 because the highest rollout indicator
      # (which is a 16 bit integer) can be is 65,535. 100% rollout
      # needs to include the highest indicator, and 0% needs to not include
      # the lowest indicator.
      Rational(rollout, 65_536)
    end

    def inspect
      pc = (rollout_percent * 100).to_f.round(1)
      "<#{pc}% of those matching: #{constraints}>"
    end

    def ==(other)
      return false unless other.is_a?(self.class)
      other.rollout == rollout && other.constraints == constraints
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
determinator-0.10.0 lib/determinator/target_group.rb
determinator-0.9.1 lib/determinator/target_group.rb
determinator-0.8.0 lib/determinator/target_group.rb
determinator-0.7.0 lib/determinator/target_group.rb
determinator-0.6.2 lib/determinator/target_group.rb
determinator-0.5.0 lib/determinator/target_group.rb
determinator-0.4.0 lib/determinator/target_group.rb
determinator-0.3.0 lib/determinator/target_group.rb
determinator-0.2.0 lib/determinator/target_group.rb
determinator-0.1.1 lib/determinator/target_group.rb
determinator-0.1.0 lib/determinator/target_group.rb