ruby_list_comprehension 0.0.5 → 0.0.6
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/ruby_list_comprehension.rb +4 -3
- 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: ec77e764d2dea6b44fb3fe9bd9e7900b3ff421485701b77595d24d269182c003
|
4
|
+
data.tar.gz: 924ba3849ab8533879e18c628c282e7fdef3acfd5f42a775905facd11d4f6ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2339f84f63e976850aa2dd08bca7b3524e07a61e18bc666c805d337da34b9ce74567dd6eb9b8bcb9ac9a930cf8b268619846b423ad6b8a13416aa332214ec633
|
7
|
+
data.tar.gz: ff4c6ee591f04fac8a1dd1110584ad515558d1f5e6496654debe1815d1af2b2b218e5c32f1a82de00576c51eef1ca6834ba8b0749a8085628b39745734159331
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'benchmark'
|
3
3
|
class ListComprehension
|
4
4
|
|
5
|
-
attr_reader :c, :version, :cache
|
5
|
+
attr_reader :c, :version, :cache, :caching
|
6
6
|
def [](*args)
|
7
7
|
c[*args]
|
8
8
|
end
|
@@ -12,6 +12,7 @@ class ListComprehension
|
|
12
12
|
@caching = true
|
13
13
|
@version = RUBY_VERSION
|
14
14
|
@c = ->x {
|
15
|
+
raise 'please use "x" as block parameter name for now' if x[3..5] != ' x '
|
15
16
|
# save a pristine copy of call for caching
|
16
17
|
y = x[0..-1]
|
17
18
|
# check for cached results
|
@@ -62,11 +63,11 @@ class ListComprehension
|
|
62
63
|
# check Ruby Version stored in @version
|
63
64
|
if @version >= '2.7.0'
|
64
65
|
return instance_eval(iterable).filter_map do |x|
|
65
|
-
instance_eval(map_condition.join(' ')) if
|
66
|
+
instance_eval(map_condition.join(' ')) if instance_eval(if_condition.join(' '))
|
66
67
|
end
|
67
68
|
else
|
68
69
|
return instance_eval(iterable).map do |x|
|
69
|
-
instance_eval(map_condition.join(' ')) if
|
70
|
+
instance_eval(map_condition.join(' ')) if instance_eval(if_condition.join(' ')).compact!
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|