Class: Cadet::NodePusher
- Inherits:
-
Object
- Object
- Cadet::NodePusher
- Includes:
- Enumerable
- Defined in:
- lib/cadet/node_pusher.rb
Instance Method Summary collapse
- #<<(othernode) ⇒ Object
- #==(other) ⇒ Object
- #=~(other) ⇒ Object
- #each ⇒ Object
- #incoming(type) ⇒ Object
-
#initialize(node, direction, type) ⇒ NodePusher
constructor
A new instance of NodePusher.
- #outgoing(type) ⇒ Object
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..getId} == other.to_a.sort_by {|n| n..getId} end |
#each ⇒ Object
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 |