delight 0.1.3 → 0.1.4
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/delight/enumerator/select_by.rb +23 -0
- data/lib/delight/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33be3483fc364798e5ab551821b8f4404709c195eaddad0dc6373b9be7b92296
|
4
|
+
data.tar.gz: 38e642bd941c1e1292dff9160aa23fabdf5cdfa499d9e81f1769acbed84469f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205d6c36bfe8c7cfd8aafb1be617cbad488f4aff7b257a5f5a5dcb5ec05bd8a9f8e61e5613a212191531c65b7f71d28a26d8adc585dd4c1cdd35f8e20894f168
|
7
|
+
data.tar.gz: 240ffb9fc46657aa2e9f8a695d06d0ca5976de1c82486c16b5238dd4a77b045e70b46c0391bae02772ca1ba1ba2779117f264c937be88f1b7ecbafc75b44529f
|
@@ -1,6 +1,29 @@
|
|
1
1
|
module Delight
|
2
2
|
module Enumerator
|
3
3
|
module SelectBy
|
4
|
+
# Filter colleciton elements using method calls and values passed as
|
5
|
+
# keyword arguments.
|
6
|
+
#
|
7
|
+
# @return [Array] containingg elements that match the passed arguments.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# ["String", 1, 3, :symbol, 'string'].select_by(class: String)
|
11
|
+
# # => ["String", 'string']
|
12
|
+
#
|
13
|
+
# Person = Struct.new(:name, :age)
|
14
|
+
#
|
15
|
+
# people = [
|
16
|
+
# Person.new("John", 30),
|
17
|
+
# Person.new("Jane", 25),
|
18
|
+
# Person.new("Alice", 30),
|
19
|
+
# ]
|
20
|
+
#
|
21
|
+
# people.select_by(age: 30)
|
22
|
+
# # => [
|
23
|
+
# # Person.new("John", 30),
|
24
|
+
# # Person.new("Alice", 30),
|
25
|
+
# # ]
|
26
|
+
#
|
4
27
|
def select_by(**)
|
5
28
|
select do |element|
|
6
29
|
collection_matcher(element, **)
|
data/lib/delight/version.rb
CHANGED