Class: SplitIoClient::NegationMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::NegationMatcher
- 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
- #attribute ⇒ Object
-
#equals?(obj) ⇒ Boolean
evaluates if the given object equals the matcher.
-
#initialize(matcher = nil) ⇒ NegationMatcher
constructor
A new instance of NegationMatcher.
-
#match?(args) ⇒ boolean
evaluates if the key matches the negation of the matcher.
- #respond_to?(method) ⇒ Boolean
- #string_type? ⇒ Boolean
-
#to_s ⇒ Object
function to print string value for this matcher.
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
#attribute ⇒ Object
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
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
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
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
30 31 32 |
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 30 def string_type? @matcher.string_type? end |
#to_s ⇒ Object
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 |