Class: SplitIoClient::NegationMatcher

Inherits:
Object
  • 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'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(matcher = nil) ⇒ NegationMatcher

Returns a new instance of NegationMatcher.



8
9
10
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 8

def initialize(matcher = nil)
  @matcher = matcher
end

Instance Method Details

#attributeObject



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

def attribute
  @matcher.attribute
end

#equals?(obj) ⇒ Boolean

evaluates if the given object equals the matcher

Parameters:

  • obj (object)

    object to be evaluated

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 40

def equals?(obj)
  if obj.nil?
    false
  elsif !obj.instance_of?(NegationMatcher)
    false
  elsif self.equal?(obj)
    true
  else
    false
  end
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



18
19
20
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 18

def match?(args)
  !@matcher.match?(args)
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#string_type?Boolean

Returns:

  • (Boolean)


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

def string_type?
  @matcher.string_type?
end

#to_sObject

function to print string value for this matcher



56
57
58
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 56

def to_s
  "not #{@matcher}"
end