Sha256: 4517c3cadfe2d229ae79b497db300f25aba0e7ddc8cd3c94a0686b511786bb0e
Contents?: true
Size: 536 Bytes
Versions: 1
Compression:
Stored size: 536 Bytes
Contents
module Redwood class Node include Redwood attr_reader :name def initialize(name=nil, parent=nil) @name = name @parent = parent end # Creates a child, adds it to children, and returns the child def add_child(name) child = self.class.new(name, self) children << child child end def [](key) selected_child = children.select {|child| child.name == key } selected_child.size.eql?(1) ? selected_child.first : selected_child end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redwood-0.0.1 | lib/redwood/node.rb |