rooted_tree 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/rooted_tree/node.rb +17 -3
- data/lib/rooted_tree/tree.rb +2 -1
- data/lib/rooted_tree/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5fb0517447c09795b818f9918deab292ff76b693
|
|
4
|
+
data.tar.gz: 9828b9590b6a2e98df0d956e5c316bde85cc982b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f4290bf9357d919e8d92da2724366a405080fddf4e91878b74849f003986de6eddc42a68bd8038fb57ce3afb5106eb23226d049a84f902e5f6b32d6d35e36ec
|
|
7
|
+
data.tar.gz: 4aaddad4f3f6f8c7f5a771889dae2a9ea5c3f4c6568a8500eb0a2f8f36fc1ee16c2f7d6d240ec117507ed40f1997ac30e1fb46c8069e995b70f27b809c8269d0
|
data/lib/rooted_tree/node.rb
CHANGED
|
@@ -38,6 +38,11 @@ module RootedTree
|
|
|
38
38
|
@first_child = duped_children.first
|
|
39
39
|
@last_child = duped_children.last
|
|
40
40
|
end
|
|
41
|
+
|
|
42
|
+
def freeze
|
|
43
|
+
super
|
|
44
|
+
children.each(&:freeze)
|
|
45
|
+
end
|
|
41
46
|
|
|
42
47
|
# Leaf?
|
|
43
48
|
#
|
|
@@ -351,13 +356,22 @@ module RootedTree
|
|
|
351
356
|
children.to_a == other.children.to_a
|
|
352
357
|
end
|
|
353
358
|
|
|
359
|
+
# Tree!
|
|
360
|
+
#
|
|
361
|
+
# Wraps the entire tree in a Tree object. The operation will freeze the node
|
|
362
|
+
# structure, making it immutable. If this node is a child the root will be
|
|
363
|
+
# found and passed to Tree.new.
|
|
364
|
+
|
|
365
|
+
def tree!
|
|
366
|
+
Tree.new root
|
|
367
|
+
end
|
|
368
|
+
|
|
354
369
|
# Tree
|
|
355
370
|
#
|
|
356
|
-
#
|
|
357
|
-
# will be found and passed to Tree.new.
|
|
371
|
+
# Duplicates the entire tree and calls #tree! on the copy.
|
|
358
372
|
|
|
359
373
|
def tree
|
|
360
|
-
|
|
374
|
+
root.dup.tree!
|
|
361
375
|
end
|
|
362
376
|
|
|
363
377
|
# Subtree!
|
data/lib/rooted_tree/tree.rb
CHANGED
data/lib/rooted_tree/version.rb
CHANGED