class PEROBS::SpaceTreeNodeLink
This class is used to form the links between the in-memory SpaceTreeNode
objects. The link is based on the address of the node in the file. The class objects transparently convert the address into a corresponding SpaceTreeNode
object and pass on all method calls.
Attributes
Public Class Methods
Create a new SpaceTreeNodeLink
object. @param tree [SpaceTree] The SpaceTree
that holds the nodes. @param node_or_address [SpaceTreeNode or SpaceTreeNodeLink
or Integer] a
SpaceTreeNode, SpaceTreeNodeLink reference or the node address in the file.
# File lib/perobs/SpaceTreeNodeLink.rb, line 43 def initialize(tree, node_or_address) @tree = tree if node_or_address.is_a?(SpaceTreeNode) || node_or_address.is_a?(SpaceTreeNodeLink) @node_address = node_or_address.node_address elsif node_or_address.is_a?(Integer) @node_address = node_or_address else PEROBS.log.fatal "Unsupported argument type #{node_or_address.class}" end end
Public Instance Methods
Compare this node to another node. @return [Boolean] true if node address is not identical, false otherwise
# File lib/perobs/SpaceTreeNodeLink.rb, line 74 def !=(node) @node_address != node.node_address end
Compare this node to another node. @return [Boolean] true if node address is identical, false otherwise
# File lib/perobs/SpaceTreeNodeLink.rb, line 68 def ==(node) @node_address == node.node_address end
Check the link to a sub-node. This method silently ignores all errors if the sub-node does not exist. @return [Boolean] True if link is OK, false otherweise
# File lib/perobs/SpaceTreeNodeLink.rb, line 81 def check_node_link(branch, stack) begin return get_node.check_node_link(branch, stack) rescue return false end end
All calls to a SpaceTreeNodeLink
object will be forwarded to the corresponding SpaceTreeNode
object. If that
# File lib/perobs/SpaceTreeNodeLink.rb, line 57 def method_missing(method, *args, &block) get_node.send(method, *args, &block) end
Make it properly introspectable.
# File lib/perobs/SpaceTreeNodeLink.rb, line 62 def respond_to?(method, include_private = false) get_node.respond_to?(method) end
@return Textual version of the SpaceTreeNode
# File lib/perobs/SpaceTreeNodeLink.rb, line 90 def to_s get_node.to_s end
Private Instance Methods
# File lib/perobs/SpaceTreeNodeLink.rb, line 96 def get_node @tree.cache.get(@node_address) end