modular_tree 0.9.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/modular_tree/algorithms.rb +14 -2
- data/lib/modular_tree/implementations.rb +6 -0
- data/lib/modular_tree/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0947ea53f44cfdfdf8c615c26217fc7bfd86b9fae98f6c234519ace576f911d
|
4
|
+
data.tar.gz: 6dc9685845668b34db4724828f777e80d1e808557c1e8b63988f23a82fdccccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e18eeb61df2ec711d51501175409ce1b085dc86d01c65ae3863f9abf4c72ff2e051dfc070541652acfdc6515859a2b7e0cf9c11ea665c5d1f9146c83ad881701
|
7
|
+
data.tar.gz: b7f8dfbd482c7c64dd8f52f52d17d2ad2b4e82ee5e0604adbc790aa576ade55c0e26456df207938656ef5314fd4601809797669c11a488ba89d861e020bee905
|
@@ -10,14 +10,14 @@ module Tree
|
|
10
10
|
include BranchesProperty
|
11
11
|
|
12
12
|
# Bottom-up
|
13
|
-
def ancestors
|
13
|
+
def ancestors # TODO: rename #parents
|
14
14
|
curr = self
|
15
15
|
a = []
|
16
16
|
a.push curr.node while curr = curr.branch
|
17
17
|
a
|
18
18
|
end
|
19
19
|
|
20
|
-
# Top-down
|
20
|
+
# Top-down # TODO: rename #ancestors
|
21
21
|
def ancestry
|
22
22
|
curr = self
|
23
23
|
a = []
|
@@ -306,6 +306,18 @@ module Tree
|
|
306
306
|
|
307
307
|
def path = @path ||= ancestry[1..-1]&.map(&:key)&.join(separator) || ""
|
308
308
|
def uid() @uid ||= [parent&.uid, key].compact.join(separator) end
|
309
|
+
|
310
|
+
def search(*args, this: true, &block)
|
311
|
+
matcher = Matcher.new(*args, &block)
|
312
|
+
curr = this ? self : branch
|
313
|
+
while curr
|
314
|
+
return curr if matcher.match?(curr)
|
315
|
+
curr = curr.branch
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
# TODO
|
320
|
+
def lookup(key) = raise NotImplementedError
|
309
321
|
end
|
310
322
|
|
311
323
|
module DotAlgorithms
|
@@ -53,6 +53,12 @@ module Tree
|
|
53
53
|
include ParentImplementation
|
54
54
|
end
|
55
55
|
|
56
|
+
module InternalRootImplementation
|
57
|
+
include RootProperty
|
58
|
+
include InternalParentImplementation
|
59
|
+
def root = @root ||= parent&.root || self
|
60
|
+
end
|
61
|
+
|
56
62
|
module ChildrenImplementation
|
57
63
|
include ChildrenProperty
|
58
64
|
include BranchesProperty
|
data/lib/modular_tree/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modular_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: constrain
|