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-2.5.0 lib/determinator/target_group.rb
determinator-2.4.4 lib/determinator/target_group.rb
determinator-2.4.3 lib/determinator/target_group.rb
determinator-2.4.2 lib/determinator/target_group.rb
determinator-2.4.0 lib/determinator/target_group.rb
determinator-2.3.1 lib/determinator/target_group.rb
determinator-2.3.0 lib/determinator/target_group.rb
determinator-2.2.1 lib/determinator/target_group.rb
determinator-2.2.0 lib/determinator/target_group.rb
determinator-2.1.0 lib/determinator/target_group.rb
determinator-2.0.0 lib/determinator/target_group.rb
determinator-1.2.0 lib/determinator/target_group.rb
determinator-1.1.2 lib/determinator/target_group.rb
determinator-1.1.1 lib/determinator/target_group.rb
determinator-1.1.0 lib/determinator/target_group.rb
determinator-1.0.0 lib/determinator/target_group.rb
determinator-0.12.1 lib/determinator/target_group.rb
determinator-0.12.0 lib/determinator/target_group.rb
determinator-0.11.1 lib/determinator/target_group.rb
determinator-0.11.0 lib/determinator/target_group.rb