OSDN Git Service

add Redmine trunk rev 3089
[redminele/redminele.git] / redmine / vendor / gems / rubytree-0.5.2 / README
1 \r
2    __       _           _\r
3    /__\_   _| |__  _   _| |_ _ __ ___  ___\r
4   / \// | | | '_ \| | | | __| '__/ _ \/ _ \\r
5  / _  \ |_| | |_) | |_| | |_| | |  __/  __/\r
6  \/ \_/\__,_|_.__/ \__, |\__|_|  \___|\___|\r
7                   |___/\r
8 \r
9   (c) 2006, 2007 Anupam Sengupta\r
10   http://rubytree.rubyforge.org\r
11 \r
12 Rubytree is a simple implementation of the generic Tree data structure.  This\r
13 implementation is node-centric, where the individual nodes on the tree are the\r
14 primary objects and drive the structure.\r
15 \r
16 == INSTALL:\r
17 \r
18 Rubytree is an open source project and is hosted at:\r
19 \r
20    http://rubytree.rubyforge.org\r
21 \r
22 Rubytree can be downloaded as a Rubygem or as a tar/zip file from:\r
23 \r
24    http://rubyforge.org/frs/?group_id=1215&release_id=8817\r
25 \r
26 The file-name is one of:\r
27 \r
28     rubytree-<VERSION>.gem - The Rubygem\r
29     rubytree-<VERSION>.tgz - GZipped source files\r
30     rubytree-<VERSION>.zip - Zipped  source files\r
31 \r
32 Download the appropriate file-type for your system.\r
33 \r
34 It is recommended to install Rubytree as a Ruby Gem, as this is an easy way to\r
35 keep the version updated, and keep multiple versions of the library available on\r
36 your system.\r
37 \r
38 === Installing the Gem\r
39 \r
40 To Install the Gem, from a Terminal/CLI command prompt, issue the command:\r
41 \r
42    gem install rubytree\r
43 \r
44 This should install the gem file for Rubytree. Note that you may need to be a\r
45 super-user (root) to successfully install the gem.\r
46 \r
47 === Installing from the tgz/zip file\r
48 \r
49 Extract the archive file (tgz or zip) and run the following command from the\r
50 top-level source directory:\r
51 \r
52     ruby ./setup.rb\r
53 \r
54 You may need administrator/super-user privileges to complete the setup using\r
55 this method.\r
56 \r
57 == DOCUMENTATION:\r
58 \r
59 The primary class for this implementation is Tree::TreeNode. See the\r
60 class documentation for an usage example.\r
61 \r
62 From a command line/terminal prompt, you can issue the following command to view\r
63 the text mode ri documentation:\r
64 \r
65     ri Tree::TreeNode\r
66 \r
67 Documentation on the web is available at:\r
68 \r
69 http://rubytree.rubyforge.org/rdoc\r
70 \r
71 == EXAMPLE:\r
72 \r
73 The following code-snippet implements this tree structure:\r
74 \r
75                  +------------+\r
76                  |    ROOT    |\r
77                  +-----+------+\r
78          +-------------+------------+\r
79          |                          |\r
80  +-------+-------+          +-------+-------+\r
81  |  CHILD 1      |          |  CHILD 2      |\r
82  +-------+-------+          +---------------+\r
83          |\r
84          |\r
85  +-------+-------+\r
86  | GRANDCHILD 1  |\r
87  +---------------+\r
88 \r
89  require 'tree'\r
90 \r
91  myTreeRoot = Tree::TreeNode.new("ROOT", "Root Content")\r
92 \r
93  myTreeRoot << Tree::TreeNode.new("CHILD1", "Child1 Content") << Tree::TreeNode.new("GRANDCHILD1", "GrandChild1 Content")\r
94 \r
95  myTreeRoot << Tree::TreeNode.new("CHILD2", "Child2 Content")\r
96 \r
97  myTreeRoot.printTree\r
98 \r
99  child1 = myTreeRoot["CHILD1"]\r
100 \r
101  grandChild1 = myTreeRoot["CHILD1"]["GRANDCHILD1"]\r
102 \r
103  siblingsOfChild1Array = child1.siblings\r
104 \r
105  immediateChildrenArray = myTreeRoot.children\r
106 \r
107  # Process all nodes\r
108 \r
109  myTreeRoot.each { |node| node.content.reverse }\r
110 \r
111  myTreeRoot.remove!(child1) # Remove the child\r
112 \r
113 == LICENSE:\r
114 \r
115 Rubytree is licensed under BSD license.\r
116 \r
117 Copyright (c) 2006, 2007 Anupam Sengupta\r
118 \r
119 All rights reserved.\r
120 \r
121 Redistribution and use in source and binary forms, with or without modification,\r
122 are permitted provided that the following conditions are met:\r
123 \r
124 - Redistributions of source code must retain the above copyright notice, this\r
125   list of conditions and the following disclaimer.\r
126 \r
127 - Redistributions in binary form must reproduce the above copyright notice, this\r
128   list of conditions and the following disclaimer in the documentation and/or\r
129   other materials provided with the distribution.\r
130 \r
131 - Neither the name of the organization nor the names of its contributors may\r
132   be used to endorse or promote products derived from this software without\r
133   specific prior written permission.\r
134 \r
135 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
136 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
137 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
138 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\r
139 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
140 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
141 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
142 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
143 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
144 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
145 \r
146 \r
147 (Document Revision: $Revision: 1.16 $ by $Author: anupamsg $)\r