Class: Neo4j::Core::Rels::Traverser
- Inherits:
-
Object
- Object
- Neo4j::Core::Rels::Traverser
- Includes:
- Enumerable
- Defined in:
- lib/neo4j-core/rels/traverser.rb
Overview
Traverse relationships of depth one from one node. This object is returned from the Neo4j::Node#rels method.
Instance Attribute Summary (collapse)
-
- (Object) dir
readonly
Returns the value of attribute dir.
-
- (Object) node
readonly
Returns the value of attribute node.
-
- (Object) types
readonly
Returns the value of attribute types.
Instance Method Summary (collapse)
-
- (Object) between(between)
(also: #to_other)
Specifies that we only want relationship to the given node.
-
- (Object) both
Specifies that we want both incoming and outgoing direction.
-
- (Object) del
Deletes all the relationships.
-
- (Object) each
Implements the Ruby Enumerable mixin.
-
- (true, false) empty?
If there are no relationships of specified dir and type(s).
-
- (Object) incoming
Specifies that we only want incoming relationships.
-
- (Traverser) initialize(node, types, dir = :both)
constructor
Called from Neo4j::Core::Node#rels.
-
- (Object) iterator
The Java Iterator.
-
- (true, false) match_between?(rel)
True if it match the specified other node.
-
- (Object) outgoing
Specifies that only outgoing relationships is wanted.
- - (Object) to_s
Constructor Details
- (Traverser) initialize(node, types, dir = :both)
Called from Neo4j::Core::Node#rels
17 18 19 20 21 |
# File 'lib/neo4j-core/rels/traverser.rb', line 17 def initialize(node, types, dir = :both) @node = node @types = types @dir = dir end |
Instance Attribute Details
- (Object) dir (readonly)
Returns the value of attribute dir
13 14 15 |
# File 'lib/neo4j-core/rels/traverser.rb', line 13 def dir @dir end |
- (Object) node (readonly)
Returns the value of attribute node
12 13 14 |
# File 'lib/neo4j-core/rels/traverser.rb', line 12 def node @node end |
- (Object) types (readonly)
Returns the value of attribute types
14 15 16 |
# File 'lib/neo4j-core/rels/traverser.rb', line 14 def types @types end |
Instance Method Details
- (Object) between(between) Also known as: to_other
Specifies that we only want relationship to the given node
61 62 63 64 |
# File 'lib/neo4j-core/rels/traverser.rb', line 61 def between(between) @between = between._java_node self end |
- (Object) both
Specifies that we want both incoming and outgoing direction
76 77 78 79 |
# File 'lib/neo4j-core/rels/traverser.rb', line 76 def both @dir = :both self end |
- (Object) del
Deletes all the relationships
69 70 71 |
# File 'lib/neo4j-core/rels/traverser.rb', line 69 def del each { |rel| rel.del } end |
- (Object) each
Implements the Ruby Enumerable mixin
28 29 30 31 32 |
# File 'lib/neo4j-core/rels/traverser.rb', line 28 def each iterator.each do |rel| yield rel.wrapper if match_between?(rel) end end |
- (true, false) empty?
If there are no relationships of specified dir and type(s)
35 36 37 |
# File 'lib/neo4j-core/rels/traverser.rb', line 35 def empty? first == nil end |
- (Object) incoming
Specifies that we only want incoming relationships
83 84 85 86 |
# File 'lib/neo4j-core/rels/traverser.rb', line 83 def incoming @dir = :incoming self end |
- (Object) iterator
The Java Iterator
40 41 42 |
# File 'lib/neo4j-core/rels/traverser.rb', line 40 def iterator @node._rels(@dir, *@types) end |
- (true, false) match_between?(rel)
True if it match the specified other node
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/neo4j-core/rels/traverser.rb', line 46 def match_between?(rel) if @between.nil? true elsif @dir == :outgoing rel._end_node == @between elsif @dir == :incoming rel._start_node == @between else rel._start_node == @between || rel._end_node == @between end end |
- (Object) outgoing
Specifies that only outgoing relationships is wanted.
90 91 92 93 |
# File 'lib/neo4j-core/rels/traverser.rb', line 90 def outgoing @dir = :outgoing self end |
- (Object) to_s
23 24 25 |
# File 'lib/neo4j-core/rels/traverser.rb', line 23 def to_s "#{self.class} [types: #{@types.join(',')} dir:#{@dir}]" end |