OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/vendor/gems/rubytree-0.5.2/README

148 lines
4.7 KiB

__ _ _
/__\_ _| |__ _ _| |_ _ __ ___ ___
/ \// | | | '_ \| | | | __| '__/ _ \/ _ \
/ _ \ |_| | |_) | |_| | |_| | | __/ __/
\/ \_/\__,_|_.__/ \__, |\__|_| \___|\___|
|___/
(c) 2006, 2007 Anupam Sengupta
http://rubytree.rubyforge.org
Rubytree is a simple implementation of the generic Tree data structure. This
implementation is node-centric, where the individual nodes on the tree are the
primary objects and drive the structure.
== INSTALL:
Rubytree is an open source project and is hosted at:
http://rubytree.rubyforge.org
Rubytree can be downloaded as a Rubygem or as a tar/zip file from:
http://rubyforge.org/frs/?group_id=1215&release_id=8817
The file-name is one of:
rubytree-<VERSION>.gem - The Rubygem
rubytree-<VERSION>.tgz - GZipped source files
rubytree-<VERSION>.zip - Zipped source files
Download the appropriate file-type for your system.
It is recommended to install Rubytree as a Ruby Gem, as this is an easy way to
keep the version updated, and keep multiple versions of the library available on
your system.
=== Installing the Gem
To Install the Gem, from a Terminal/CLI command prompt, issue the command:
gem install rubytree
This should install the gem file for Rubytree. Note that you may need to be a
super-user (root) to successfully install the gem.
=== Installing from the tgz/zip file
Extract the archive file (tgz or zip) and run the following command from the
top-level source directory:
ruby ./setup.rb
You may need administrator/super-user privileges to complete the setup using
this method.
== DOCUMENTATION:
The primary class for this implementation is Tree::TreeNode. See the
class documentation for an usage example.
From a command line/terminal prompt, you can issue the following command to view
the text mode ri documentation:
ri Tree::TreeNode
Documentation on the web is available at:
http://rubytree.rubyforge.org/rdoc
== EXAMPLE:
The following code-snippet implements this tree structure:
+------------+
| ROOT |
+-----+------+
+-------------+------------+
| |
+-------+-------+ +-------+-------+
| CHILD 1 | | CHILD 2 |
+-------+-------+ +---------------+
|
|
+-------+-------+
| GRANDCHILD 1 |
+---------------+
require 'tree'
myTreeRoot = Tree::TreeNode.new("ROOT", "Root Content")
myTreeRoot << Tree::TreeNode.new("CHILD1", "Child1 Content") << Tree::TreeNode.new("GRANDCHILD1", "GrandChild1 Content")
myTreeRoot << Tree::TreeNode.new("CHILD2", "Child2 Content")
myTreeRoot.printTree
child1 = myTreeRoot["CHILD1"]
grandChild1 = myTreeRoot["CHILD1"]["GRANDCHILD1"]
siblingsOfChild1Array = child1.siblings
immediateChildrenArray = myTreeRoot.children
# Process all nodes
myTreeRoot.each { |node| node.content.reverse }
myTreeRoot.remove!(child1) # Remove the child
== LICENSE:
Rubytree is licensed under BSD license.
Copyright (c) 2006, 2007 Anupam Sengupta
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- Neither the name of the organization nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(Document Revision: $Revision: 1.16 $ by $Author: anupamsg $)