Class: Cadet::NodePusher

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/cadet/node_pusher.rb

Instance Method Summary collapse

Constructor Details

#initialize(node, direction, type) ⇒ NodePusher

Returns a new instance of NodePusher.



5
6
7
8
9
# File 'lib/cadet/node_pusher.rb', line 5

def initialize(node, direction, type)
  @node = node
  @type = type
  @direction = direction
end

Instance Method Details

#<<(othernode) ⇒ Object



17
18
19
# File 'lib/cadet/node_pusher.rb', line 17

def << (othernode)
  @direction == :outgoing ? @node.create_outgoing(othernode, @type) : othernode.create_outgoing(@node, @type)
end

#==(other) ⇒ Object



28
29
30
# File 'lib/cadet/node_pusher.rb', line 28

def ==(other)
  self.to_a == other.to_a
end

#=~(other) ⇒ Object



32
33
34
# File 'lib/cadet/node_pusher.rb', line 32

def =~(other)
  self.to_a.sort_by {|n| n.underlying.getId} == other.to_a.sort_by {|n| n.underlying.getId}
end

#eachObject



11
12
13
14
15
# File 'lib/cadet/node_pusher.rb', line 11

def each
  @node.each_relationship(@direction, @type) do |rel|
    yield rel.get_other_node(@node)
  end
end

#incoming(type) ⇒ Object



24
25
26
# File 'lib/cadet/node_pusher.rb', line 24

def incoming(type)
  Traverser.new to_a, :incoming, type
end

#outgoing(type) ⇒ Object



21
22
23
# File 'lib/cadet/node_pusher.rb', line 21

def outgoing(type)
  Traverser.new to_a, :outgoing, type
end