rubytree 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/tree.rb +4 -4
- data/test/testtree.rb +1 -0
- metadata +24 -17
data/Rakefile
CHANGED
data/lib/tree.rb
CHANGED
@@ -209,13 +209,13 @@ module Tree
|
|
209
209
|
end
|
210
210
|
|
211
211
|
# Returns an array of siblings for this node.
|
212
|
-
# If a block is provided,
|
213
|
-
# nodes to the block.
|
212
|
+
# If a block is provided, yields each of the sibling
|
213
|
+
# nodes to the block. The root always has nil siblings.
|
214
214
|
def siblings
|
215
|
+
return nil if isRoot?
|
215
216
|
if block_given?
|
216
|
-
return nil if isRoot?
|
217
217
|
for sibling in parent.children
|
218
|
-
|
218
|
+
yield sibling if sibling != self
|
219
219
|
end
|
220
220
|
else
|
221
221
|
siblings = []
|
data/test/testtree.rb
CHANGED
@@ -36,6 +36,7 @@ class TC_TreeTest < Test::Unit::TestCase
|
|
36
36
|
assert(@root.isRoot?, "Should identify as root")
|
37
37
|
assert(!@root.hasChildren?, "Cannot have any children")
|
38
38
|
assert_equal(1, @root.size, "Number of nodes should be one")
|
39
|
+
assert_nil(@root.siblings, "Root cannot have any children")
|
39
40
|
|
40
41
|
assert_raise(RuntimeError) { Tree::TreeNode.new(nil) }
|
41
42
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: rubytree
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date:
|
6
|
+
version: 0.2.3
|
7
|
+
date: 2007-01-05 00:00:00 -07:00
|
8
8
|
summary: Ruby implementation of the Tree data structure.
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: anupamsg@gmail.com
|
12
12
|
homepage:
|
13
13
|
rubyforge_project:
|
@@ -18,26 +18,33 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
27
29
|
authors:
|
28
|
-
|
30
|
+
- Anupam Sengupta
|
29
31
|
files:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
- Rakefile
|
33
|
+
- README
|
34
|
+
- lib/tree.rb
|
35
|
+
- test/person.rb
|
36
|
+
- test/testtree.rb
|
35
37
|
test_files:
|
36
|
-
|
38
|
+
- test/testtree.rb
|
37
39
|
rdoc_options: []
|
40
|
+
|
38
41
|
extra_rdoc_files:
|
39
|
-
|
42
|
+
- README
|
40
43
|
executables: []
|
44
|
+
|
41
45
|
extensions: []
|
46
|
+
|
42
47
|
requirements: []
|
43
|
-
|
48
|
+
|
49
|
+
dependencies: []
|
50
|
+
|