Class: PEROBS::SpaceTreeNodeLink
- Inherits:
-
Object
- Object
- PEROBS::SpaceTreeNodeLink
- Defined in:
- lib/perobs/SpaceTreeNodeLink.rb
Overview
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.
Instance Attribute Summary collapse
-
#node_address ⇒ Object
readonly
Returns the value of attribute node_address.
Instance Method Summary collapse
-
#!=(node) ⇒ Boolean
Compare this node to another node.
-
#==(node) ⇒ Boolean
Compare this node to another node.
-
#check_node_link(branch, stack) ⇒ Boolean
Check the link to a sub-node.
-
#initialize(tree, node_or_address) ⇒ SpaceTreeNodeLink
constructor
Create a new SpaceTreeNodeLink object.
-
#method_missing(method, *args, &block) ⇒ Object
All calls to a SpaceTreeNodeLink object will be forwarded to the corresponding SpaceTreeNode object.
-
#respond_to?(method, include_private = false) ⇒ Boolean
Make it properly introspectable.
-
#to_s ⇒ Object
Textual version of the SpaceTreeNode.
Constructor Details
#initialize(tree, node_or_address) ⇒ SpaceTreeNodeLink
Create a new SpaceTreeNodeLink object.
43 44 45 46 47 48 49 50 51 52 53 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
All calls to a SpaceTreeNodeLink object will be forwarded to the corresponding SpaceTreeNode object. If that
57 58 59 |
# File 'lib/perobs/SpaceTreeNodeLink.rb', line 57 def method_missing(method, *args, &block) get_node.send(method, *args, &block) end |
Instance Attribute Details
#node_address ⇒ Object (readonly)
Returns the value of attribute node_address.
36 37 38 |
# File 'lib/perobs/SpaceTreeNodeLink.rb', line 36 def node_address @node_address end |
Instance Method Details
#!=(node) ⇒ Boolean
Compare this node to another node.
74 75 76 |
# File 'lib/perobs/SpaceTreeNodeLink.rb', line 74 def !=(node) @node_address != node.node_address end |
#==(node) ⇒ Boolean
Compare this node to another node.
68 69 70 |
# File 'lib/perobs/SpaceTreeNodeLink.rb', line 68 def ==(node) @node_address == node.node_address end |
#check_node_link(branch, stack) ⇒ Boolean
Check the link to a sub-node. This method silently ignores all errors if the sub-node does not exist.
81 82 83 84 85 86 87 |
# 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 |
#respond_to?(method, include_private = false) ⇒ Boolean
Make it properly introspectable.
62 63 64 |
# File 'lib/perobs/SpaceTreeNodeLink.rb', line 62 def respond_to?(method, include_private = false) get_node.respond_to?(method) end |
#to_s ⇒ Object
Returns Textual version of the SpaceTreeNode.
90 91 92 |
# File 'lib/perobs/SpaceTreeNodeLink.rb', line 90 def to_s get_node.to_s end |