ruby_list_comprehension 0.0.3 → 0.0.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/ruby_list_comprehension.rb +3 -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: a09a6c55f3c18f9f89ab19ba482e94c50862cb20f251fd5c83755535e248cd64
|
4
|
+
data.tar.gz: f1812c165243cd0bc3e3c1fd91415e1c1bed2bcb314a4d8c88b48d1d5e5d3683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88b9c43e97223089d22f1e921f1933f39d721ad82316c7cded62175254e8d538220ce4fa40e88a61ed2d0f5b1081fd7b54aed8b8d3fc7af2ee48565f10344e41
|
7
|
+
data.tar.gz: 88ceb53a0fe56ba5342acdd361b18daf0ba7cbeb9a1f5a2a90cad4f1d84661c59ccb814dfbbc355834b8bb1e0d36c2a650b71b75e7edc9cda8ed7270ce3b9e6e
|
@@ -30,20 +30,20 @@ class ListComprehension
|
|
30
30
|
if_condition = arr.include?('if') ? arr[arr.index('if') + 1...-1] : ['true']
|
31
31
|
map_condition = arr[arr.index('do') + 1...(arr.index('if') || arr.index('end'))]
|
32
32
|
if (map_condition == [arr[1]]) && (if_condition == ['true'] || if_condition == true)
|
33
|
-
p "no method needed"
|
33
|
+
# p "no method needed"
|
34
34
|
res = eval(arr[3])
|
35
35
|
return res.is_a?(Array) ? res : [res]
|
36
36
|
end
|
37
37
|
self.class.send(:define_method,'lc') do |arr|
|
38
38
|
if map_condition == [arr[1]]
|
39
|
-
p 'filter'
|
39
|
+
# p 'filter'
|
40
40
|
return eval(iterable).filter do |x|
|
41
41
|
eval(if_condition.join(' '))
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
if if_condition == ['true'] || if_condition == true
|
46
|
-
p 'map'
|
46
|
+
# p 'map'
|
47
47
|
return eval(iterable).map do |x|
|
48
48
|
eval(map_condition.join(' '))
|
49
49
|
end
|