Sha256: 88788bde8acbd2d99b26321544fed019c32e835224dddca3392f1688ee80af38
Contents?: true
Size: 798 Bytes
Versions: 5
Compression:
Stored size: 798 Bytes
Contents
module Cadet class NodeTraverser include Enumerable def initialize(node, direction, type) @node = node @type = type @direction = direction end def each @node.each_relationship(@direction, @type) do |rel| yield rel.get_other_node(@node) end end def << (othernode) @direction == :outgoing ? @node.create_outgoing(othernode, @type) : othernode.create_outgoing(@node, @type) end def outgoing(type) PathTraverser.new to_a, :outgoing, type end def incoming(type) PathTraverser.new to_a, :incoming, type end def ==(other) self.to_a == other.to_a end def =~(other) self.to_a.sort_by {|n| n.underlying.getId} == other.to_a.sort_by {|n| n.underlying.getId} end end end
Version data entries
5 entries across 5 versions & 1 rubygems