Class: SexpPath::Matcher::Not

Inherits:
Base
  • Object
show all
Defined in:
lib/sexp_path/matcher/not.rb

Overview

See SexpQueryBuilder.not

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#&, #-@, #>>, #|

Methods included from Traverse

#capture_as, #replace_sexp, #search, #search_each

Constructor Details

#initialize(value) ⇒ Not

Creates a Matcher which will match any Sexp that does not match the value



6
7
8
# File 'lib/sexp_path/matcher/not.rb', line 6

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/sexp_path/matcher/not.rb', line 3

def value
  @value
end

Instance Method Details

#inspectObject



17
18
19
# File 'lib/sexp_path/matcher/not.rb', line 17

def inspect
  "is_not(#{value.inspect})"
end

#satisfy?(o, data = {}) ⇒ Boolean

Satisfied if a o does not match the value

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/sexp_path/matcher/not.rb', line 11

def satisfy?(o, data={})
  return nil if value.is_a?(Sexp) ? value.satisfy?(o, data) : value == o

  capture_match o, {}
end