code-ruby 1.6.13 → 1.7.0
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/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/object/list.rb +29 -0
- 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: 33ef71e66cc6f4693a344a3df19db365beb8a1c375ef74fa7fa0876bf03a4339
|
4
|
+
data.tar.gz: 47b827ad96ccf65cbd3530e592ee7c804ae593c64ca31a22369a924b3a04cdfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351bf9f83d635bcafb4ef387ebd796e981c186c64ac865b17e5f6dbafa6b5bb863ced90d2521318b7c48c5f03be6de71d8c43592595ba4aeb542b6b82f5153dd
|
7
|
+
data.tar.gz: 183791c8d842a780ca2721c68acc9bb15c5261ba8e0e06023b0f1bc07c867c979fb2a2889ae5faee4b1dc255f55d0dc997cbb4a26e0c0c5b49c7b0d3add0ef47
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
data/lib/code/object/list.rb
CHANGED
@@ -193,6 +193,9 @@ class Code
|
|
193
193
|
when "none?"
|
194
194
|
sig(args) { (Function | Class).maybe }
|
195
195
|
code_none?(code_value, **globals)
|
196
|
+
when "all?"
|
197
|
+
sig(args) { (Function | Class).maybe }
|
198
|
+
code_all?(code_value, **globals)
|
196
199
|
when "reduce"
|
197
200
|
sig(args) { (Function | Class).maybe }
|
198
201
|
code_reduce(code_value, **globals)
|
@@ -781,6 +784,32 @@ class Code
|
|
781
784
|
)
|
782
785
|
end
|
783
786
|
|
787
|
+
def code_all?(argument = nil, **globals)
|
788
|
+
code_argument = argument.to_code
|
789
|
+
|
790
|
+
index = 0
|
791
|
+
|
792
|
+
Boolean.new(
|
793
|
+
raw.all? do |code_element|
|
794
|
+
if code_argument.is_a?(Function)
|
795
|
+
code_argument
|
796
|
+
.call(
|
797
|
+
arguments: List.new([code_element, Integer.new(index), self]),
|
798
|
+
**globals
|
799
|
+
)
|
800
|
+
.truthy?
|
801
|
+
.tap { index += 1 }
|
802
|
+
elsif code_argument.is_a?(Class)
|
803
|
+
code_element.is_a?(code_argument.raw).tap { index += 1 }
|
804
|
+
else
|
805
|
+
true.tap { index += 1 }
|
806
|
+
end
|
807
|
+
rescue Error::Next => e
|
808
|
+
e.code_value.truthy?.tap { index += 1 }
|
809
|
+
end
|
810
|
+
)
|
811
|
+
end
|
812
|
+
|
784
813
|
def code_reduce(argument = nil, **globals)
|
785
814
|
code_argument = argument.to_code
|
786
815
|
|