Sha256: 9dfe1992c0e61c8346267f52e23106382c66b25559e0fd567bc536ec2ba8a293

Contents?: true

Size: 905 Bytes

Versions: 12

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true

module SplitIoClient
  class LessThanOrEqualToSemverMatcher < Matcher
    MATCHER_TYPE = 'LESS_THAN_OR_EQUAL_TO_SEMVER'

    attr_reader :attribute

    def initialize(attribute, string_value, logger, validator)
      super(logger)
      @validator = validator
      @attribute = attribute
      @semver = SplitIoClient::Semver.build(string_value, logger)
      @logger = logger
    end

    def match?(args)
      return false unless verify_semver_arg?(args, 'LessThanOrEqualsToSemverMatcher')

      value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger)
      return false unless check_semver_value_to_match(value_to_match, MATCHER_TYPE)

      matches = [0, -1].include?(value_to_match.compare(@semver))
      @logger.debug("[LessThanOrEqualsToSemverMatcher] #{value_to_match} matches -> #{matches}")
      matches
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
splitclient-rb-8.5.0-java lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.5.0 lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.5.0.pre.rc1-java lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.5.0.pre.rc1 lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.1.pre.rc1-java lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.1.pre.rc1 lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.0-java lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.0 lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.0.pre.rc1-java lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.0.pre.rc1 lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.0.rc.1-java lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
splitclient-rb-8.4.0.rc.1 lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb