Class: Neo4jr::StopEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4jr/stop_evaluator.rb

Overview

Constant Summary collapse

DEPTH_ONE =
org.neo4j.graphdb.StopEvaluator::DEPTH_ONE
END_OF_GRAPH =
org.neo4j.graphdb.StopEvaluator::END_OF_GRAPH

Class Method Summary collapse

Class Method Details

.at(depth) ⇒ Object

Creates a new StopEvaluator on the fly that will stop traversing the graph when the depth specified is reached

Examples:

Stop.at(4)


34
35
36
37
38
# File 'lib/neo4jr/stop_evaluator.rb', line 34

def self.at(depth)
  self.when do |position|
    position.depth >= depth
  end
end

.when(&block) ⇒ Object

Creates a new StopEvaluator on the fly that delgates to the passed in block to use with the traverse method. The block should return either true or false See api.neo4j.org/current/org/neo4j/api/core/StopEvaluator.html#isStopNode(org.neo4j.api.core.TraversalPosition)

Examples:

Stop.when do |current_position|
  current_position.depth > 3 && current_position.previousNode[:active] == false
end


17
18
19
20
21
22
23
24
25
26
# File 'lib/neo4jr/stop_evaluator.rb', line 17

def self.when(&block)
  instance = new
  instance.instance_variable_set(:@evaluator_block, block)
  instance.instance_eval do
    def isStopNode(position)
      @evaluator_block.call(position)
    end
  end
  instance
end