modular_tree 0.5.0 → 0.7.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 +4 -2
- data/lib/modular_tree/matcher.rb +3 -2
- data/lib/modular_tree/pool.rb +2 -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: 70c50cd21f7eb027dcb0560bb164268c929860f61e2912dfbb1a0fd1576f5869
|
4
|
+
data.tar.gz: 120a0efd4e6dda689412e3618267645e4252ba6b24c8949203162a2c0b979fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62af79315ea3ec5c46e47b9e8cd1807b0f6dd33ee914d1a12b37cf8e0006bd2a2be6381e033e1883da88884bcae2e4ffb5a4e66b4d3ca3026d09721ba4e5c9d0
|
7
|
+
data.tar.gz: 12a75c54c67fd37c920ec4c663cd6199038c713c86d79f14a11143432f79ab1621115e0af7a1266dfecb8a56e5c073d8bf5e30b485e17af21accf840c78f7b4c
|
@@ -80,9 +80,11 @@ module Tree
|
|
80
80
|
# Filter children. Doesn't recurse. If a block is given, it should return
|
81
81
|
# truish to select a child node
|
82
82
|
#
|
83
|
+
# The match expression can also be a list of classes (instead of an array of classes)
|
84
|
+
#
|
83
85
|
# TODO: Maybe make #children an Array extended with filtering
|
84
|
-
def choose(
|
85
|
-
matcher = Matcher.new(
|
86
|
+
def choose(*args, &block)
|
87
|
+
matcher = Matcher.new(*args, &block)
|
86
88
|
if block_given?
|
87
89
|
a = []
|
88
90
|
each_branch { |branch, key| a << branch if matcher.match? branch }
|
data/lib/modular_tree/matcher.rb
CHANGED
@@ -27,9 +27,10 @@ module Tree
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def initialize(
|
30
|
+
def initialize(*args, &block)
|
31
|
+
expr = args.size == 1 ? args.first : args
|
31
32
|
constrain expr, Proc, Symbol, Class, [Class], true, false, nil
|
32
|
-
expr.nil? == block_given? or raise ArgumentError
|
33
|
+
expr.nil? == block_given? or raise ArgumentError, "Expected either an argument or a block"
|
33
34
|
@expr = (expr.nil? ? block : expr)
|
34
35
|
end
|
35
36
|
|
data/lib/modular_tree/pool.rb
CHANGED
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.7.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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: constrain
|