class WhiteCloth::DataStructures::StandardNode
Public Class Methods
new(node_id, content)
click to toggle source
Constructors
Calls superclass method
# File lib/data_structures/standard_node.rb, line 29 def initialize(node_id, content) super(node_id, content) end
Public Instance Methods
<<(child_node)
click to toggle source
Add a new child node to the current node.
# File lib/data_structures/standard_node.rb, line 38 def << (child_node) self.add(child_node) end
[](block_name)
click to toggle source
Look for the designated block within tree starting at the current node. If the block_name
is nil
or ROOT
, than we return the root of the current tree (i.e. ourselves).
# File lib/data_structures/standard_node.rb, line 44 def [] (block_name) # We need to work out which node has the right content. Since # the nodes are effectively unordered, we have to look (potentially) # at every node unless block_name.nil? or block_name == "ROOT" self.each{|child| if child.content === block_name then return child end } return nil else return self end end