Class: Neo4j::Core::Traversal::FilterPredicate

Inherits:
Object
  • Object
show all
Includes:
Java::OrgNeo4jGraphdbTraversal::Evaluator
Defined in:
lib/neo4j-core/traversal/filter_predicate.rb

Overview

Implements the Neo4j Predicate Java interface, only used internally.

Instance Method Summary collapse

Constructor Details

#initializeFilterPredicate

Returns a new instance of FilterPredicate.



9
10
11
# File 'lib/neo4j-core/traversal/filter_predicate.rb', line 9

def initialize
  @procs = []
end

Instance Method Details

#add(proc) ⇒ Object



13
14
15
# File 'lib/neo4j-core/traversal/filter_predicate.rb', line 13

def add(proc)
  @procs << proc
end

#evaluate(path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/neo4j-core/traversal/filter_predicate.rb', line 17

def evaluate(path)
  if path.length == 0
    return Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE
  end
  # find the first filter which returns false
  # if not found then we will accept this path
  if @procs.find { |p| !p.call(path) }.nil?
    Java::OrgNeo4jGraphdbTraversal::Evaluation::INCLUDE_AND_CONTINUE
  else
    Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE
  end

end