Class: SplitIoClient::NegationMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/splitclient-rb/engine/matchers/negation_matcher.rb

Overview

class to implement the negation of a matcher

Constant Summary collapse

MATCHER_TYPE =
'NEGATION_MATCHER'

Instance Method Summary collapse

Methods inherited from Matcher

#equals?

Constructor Details

#initialize(logger, matcher = nil) ⇒ NegationMatcher

Returns a new instance of NegationMatcher.



10
11
12
13
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 10

def initialize(logger, matcher = nil)
  super(logger)
  @matcher = matcher
end

Instance Method Details

#attributeObject



31
32
33
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 31

def attribute
  @matcher.attribute
end

#match?(args) ⇒ boolean

evaluates if the key matches the negation of the matcher

Parameters:

  • key (string)

    key value to be matched

Returns:

  • (boolean)

    evaluation of the negation matcher



21
22
23
24
25
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 21

def match?(args)
  matches = !@matcher.match?(args)
  @logger.log_if_debug("[NegationMatcherMatcher] Matcher #{@matcher} Arguments #{args} -> #{matches}")
  matches
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 27

def respond_to?(method)
  @matcher.respond_to? method
end

#string_type?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 35

def string_type?
  @matcher.string_type?
end

#to_sstring

function to print string value for this matcher

Returns:

  • (string)

    string value of this matcher



43
44
45
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 43

def to_s
  "not #{@matcher}"
end