modular_tree 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6913b33ae629fa98c3832ba7ae313e9948c581a53811d49648233f349b85b64
4
- data.tar.gz: eaaec7d8f9f85924c3064c18b5a88c7805baa0c70e2a7db21e798d217348b67f
3
+ metadata.gz: 70c50cd21f7eb027dcb0560bb164268c929860f61e2912dfbb1a0fd1576f5869
4
+ data.tar.gz: 120a0efd4e6dda689412e3618267645e4252ba6b24c8949203162a2c0b979fdf
5
5
  SHA512:
6
- metadata.gz: de1721efbd56c4fe8abdfb54f7d044273daf1938612e4316ef6d1344bc9b1e13bddda02da8f8b0f757d75e45f27a20674b365f28c5ecbc19c53c269217a2d7e5
7
- data.tar.gz: a9c68cf3df5204e568a575b1e510fa8974cd39baddead8a52f83edceee865284729a808e8065c898a1e717f2dc7ddfccc1b7a74056c50ff9e368199780c84e29
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(match_expr = nil, &block)
85
- matcher = Matcher.new(match_expr, &block)
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 }
@@ -27,7 +27,8 @@ module Tree
27
27
  end
28
28
  end
29
29
 
30
- def initialize(expr = nil, &block)
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
33
  expr.nil? == block_given? or raise ArgumentError, "Expected either an argument or a block"
33
34
  @expr = (expr.nil? ? block : expr)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tree
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modular_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen