qo 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.pryrc +1 -1
- data/README.md +18 -0
- data/lib/qo.rb +4 -0
- data/lib/qo/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: d097b1d36fb935478c96f41a34ac4e7e74ccdcc7
|
4
|
+
data.tar.gz: 51ea508193f5156aafc7e86a1a8de2fc0e77c36b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fc0fa88d3264cd2c8cafefea4be82bdd14bc7eed37d41d0e890d6c55a2352f784327db6d718c24c011b3d39b813501952c4f9859571b5ffaa812d5bf1c1259c
|
7
|
+
data.tar.gz: f6d73da83547b82ab3ad62822d1ce3fd7cab7feb396f5542431d015d907d66353bd126bcf3b4baf06a2951622468524420f0cd69a59ac5c56d6cede08dc40582
|
data/.pryrc
CHANGED
data/README.md
CHANGED
@@ -384,6 +384,24 @@ In this case it's trying to do a few things:
|
|
384
384
|
|
385
385
|
If no block function is provided, it assumes an identity function (`-> v { v }`) instead. If no match is found, `nil` will be returned.
|
386
386
|
|
387
|
+
Now you _can_ also use a reversed version, `match_fn` (name pending better ideas), to run with map:
|
388
|
+
|
389
|
+
```ruby
|
390
|
+
name_longer_than_three = -> person { person.name.size > 3 }
|
391
|
+
|
392
|
+
people_objects.map(&Qo.match_fn(
|
393
|
+
Qo.m(name_longer_than_three) { |person|
|
394
|
+
person.name = person.name[0..2]
|
395
|
+
person
|
396
|
+
},
|
397
|
+
Qo.m(:*)
|
398
|
+
))
|
399
|
+
|
400
|
+
# => [Person(age: 22, name: "Rob"), Person(age: 22, name: "Rob"), Person(age: 42, name: "Foo"), Person(age: 17, name: "Bar")]
|
401
|
+
```
|
402
|
+
|
403
|
+
So we just truncated everyone's name that was longer than three characters.
|
404
|
+
|
387
405
|
### 5 - Hacky Fun Time
|
388
406
|
|
389
407
|
These examples will grow over the next few weeks as I think of more fun things to do with Qo. PRs welcome if you find fun uses!
|
data/lib/qo.rb
CHANGED
data/lib/qo/version.rb
CHANGED