class PatchworkInternal::Node
Attributes
data[R]
id[R]
links[R]
Public Class Methods
new(data)
click to toggle source
# File lib/patchwork/node.rb, line 11 def initialize(data) @data = data @links = [] @id = SecureRandom.uuid end
Public Instance Methods
depth_first(&block)
click to toggle source
# File lib/patchwork/node.rb, line 36 def depth_first(&block) Traversals.depth_first(self, &block) end
link_to(node, directed = false, cost = nil)
click to toggle source
# File lib/patchwork/node.rb, line 17 def link_to(node, directed = false, cost = nil) return false if neighbor?(node) @links << Link.new(self, node, directed, cost) node.link_to(self) unless directed true end
linked_nodes()
click to toggle source
# File lib/patchwork/node.rb, line 24 def linked_nodes @links.map(&:node_end) end
neighbor?(node)
click to toggle source
# File lib/patchwork/node.rb, line 28 def neighbor?(node) @links.any? { |link| link.links_to(node) } end
visit() { |self| ... }
click to toggle source
# File lib/patchwork/node.rb, line 32 def visit yield self end