code-ruby 1.6.8 → 1.6.10
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/concerns/shared.rb +45 -0
- data/lib/code/object/class.rb +1 -1
- data/lib/code/object/decimal.rb +0 -45
- data/lib/code/object/dictionary.rb +0 -40
- data/lib/code/object/integer.rb +0 -42
- data/lib/code/object/list.rb +20 -4
- data/lib/code/object/range.rb +2 -2
- 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: cdae56ab2a8131adde0250872f81b39da931f4f93a9ccd93ae1b86a3d63aa295
|
4
|
+
data.tar.gz: f71ce983de47ef6225934531bd84d55ca30bcea0a95f813f3d023fa1839c3482
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcddbc545c4f6e72d88c2df056765cf4d6eed5e2facc1433314a75d94fc70779cb01fa741305364a96b822f99e020f9d58988b667e5532788f755db60e8cdda3
|
7
|
+
data.tar.gz: dcf9f22574c9a95b43ae5fb16158f8f31be8c0c99eb737b8bd6ca079f07044495cee9b9f6bbce3621c5286ec00caa3c35faa63e7e568529e96b30931e6777bf7
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.10
|
data/lib/code/concerns/shared.rb
CHANGED
@@ -35,6 +35,21 @@ class Code
|
|
35
35
|
when "==", "equal"
|
36
36
|
sig(args) { Object }
|
37
37
|
code_equal(code_value)
|
38
|
+
when ">", "greater_or_equal"
|
39
|
+
sig(args) { Object }
|
40
|
+
code_greater(code_value)
|
41
|
+
when ">=", "greater"
|
42
|
+
sig(args) { Object }
|
43
|
+
code_greater_or_equal(code_value)
|
44
|
+
when "<=>", "compare"
|
45
|
+
sig(args) { Object }
|
46
|
+
code_compare(code_value)
|
47
|
+
when "<", "less"
|
48
|
+
sig(args) { Object }
|
49
|
+
code_less(code_value)
|
50
|
+
when "<=", "less_or_equal"
|
51
|
+
sig(args) { Object }
|
52
|
+
code_less_or_equal(code_value)
|
38
53
|
when "===", "strict_equal"
|
39
54
|
sig(args) { Object }
|
40
55
|
code_strict_equal(code_value)
|
@@ -181,6 +196,36 @@ class Code
|
|
181
196
|
Object::Boolean.new(self == code_other)
|
182
197
|
end
|
183
198
|
|
199
|
+
def code_compare(other)
|
200
|
+
code_other = other.to_code
|
201
|
+
|
202
|
+
Object::Integer.new(self <=> code_other)
|
203
|
+
end
|
204
|
+
|
205
|
+
def code_greater(other)
|
206
|
+
code_other = other.to_code
|
207
|
+
|
208
|
+
Object::Boolean.new((self <=> code_other) > 0)
|
209
|
+
end
|
210
|
+
|
211
|
+
def code_greater_or_equal(other)
|
212
|
+
code_other = other.to_code
|
213
|
+
|
214
|
+
Object::Boolean.new((self <=> code_other) >= 0)
|
215
|
+
end
|
216
|
+
|
217
|
+
def code_less(other)
|
218
|
+
code_other = other.to_code
|
219
|
+
|
220
|
+
Object::Boolean.new((self <=> code_other) < 0)
|
221
|
+
end
|
222
|
+
|
223
|
+
def code_less_or_equal(other)
|
224
|
+
code_other = other.to_code
|
225
|
+
|
226
|
+
Object::Boolean.new((self <=> code_other) <= 0)
|
227
|
+
end
|
228
|
+
|
184
229
|
def code_exclamation_mark
|
185
230
|
Object::Boolean.new(falsy?)
|
186
231
|
end
|
data/lib/code/object/class.rb
CHANGED
data/lib/code/object/decimal.rb
CHANGED
@@ -45,24 +45,9 @@ class Code
|
|
45
45
|
when "/", "division"
|
46
46
|
sig(args) { Integer | Decimal }
|
47
47
|
code_division(code_value)
|
48
|
-
when "<", "inferior"
|
49
|
-
sig(args) { Integer | Decimal }
|
50
|
-
code_inferior(code_value)
|
51
48
|
when "<<", "left_shift"
|
52
49
|
sig(args) { Integer | Decimal }
|
53
50
|
code_left_shift(code_value)
|
54
|
-
when "<=", "inferior_or_equal"
|
55
|
-
sig(args) { Integer | Decimal }
|
56
|
-
code_inferior_or_equal(code_value)
|
57
|
-
when "<=>", "compare"
|
58
|
-
sig(args) { Integer | Decimal }
|
59
|
-
code_compare(code_value)
|
60
|
-
when ">", "superior"
|
61
|
-
sig(args) { Integer | Decimal }
|
62
|
-
code_superior(code_value)
|
63
|
-
when ">=", "superior_or_equal"
|
64
|
-
sig(args) { Integer | Decimal }
|
65
|
-
code_superior_or_equal(code_value)
|
66
51
|
when ">>", "right_shift"
|
67
52
|
sig(args) { Integer | Decimal }
|
68
53
|
code_right_shift(code_value)
|
@@ -439,12 +424,6 @@ class Code
|
|
439
424
|
Decimal.new(raw.ceil(code_n.raw))
|
440
425
|
end
|
441
426
|
|
442
|
-
def code_compare(other)
|
443
|
-
code_other = other.to_code
|
444
|
-
|
445
|
-
Integer.new(raw <=> code_other.raw)
|
446
|
-
end
|
447
|
-
|
448
427
|
def code_division(other)
|
449
428
|
code_other = other.to_code
|
450
429
|
|
@@ -458,18 +437,6 @@ class Code
|
|
458
437
|
Decimal.new(raw.floor(code_n.raw))
|
459
438
|
end
|
460
439
|
|
461
|
-
def code_inferior(other)
|
462
|
-
code_other = other.to_code
|
463
|
-
|
464
|
-
Boolean.new(raw < code_other.raw)
|
465
|
-
end
|
466
|
-
|
467
|
-
def code_inferior_or_equal(other)
|
468
|
-
code_other = other.to_code
|
469
|
-
|
470
|
-
Boolean.new(raw <= code_other.raw)
|
471
|
-
end
|
472
|
-
|
473
440
|
def code_left_shift(other)
|
474
441
|
code_other = other.to_code
|
475
442
|
|
@@ -527,18 +494,6 @@ class Code
|
|
527
494
|
Decimal.new(Math.sqrt(raw).to_s)
|
528
495
|
end
|
529
496
|
|
530
|
-
def code_superior(other)
|
531
|
-
code_other = other.to_code
|
532
|
-
|
533
|
-
Boolean.new(raw > code_other.raw)
|
534
|
-
end
|
535
|
-
|
536
|
-
def code_superior_or_equal(other)
|
537
|
-
code_other = other.to_code
|
538
|
-
|
539
|
-
Boolean.new(raw >= code_other.raw)
|
540
|
-
end
|
541
|
-
|
542
497
|
def code_to_string
|
543
498
|
String.new(raw.to_s("F"))
|
544
499
|
end
|
@@ -136,21 +136,6 @@ class Code
|
|
136
136
|
code_value = code_arguments.code_first
|
137
137
|
|
138
138
|
case code_operator.to_s
|
139
|
-
when "<", "inferior"
|
140
|
-
sig(args) { Dictionary }
|
141
|
-
code_inferior(code_value)
|
142
|
-
when "<=", "inferior_or_equal"
|
143
|
-
sig(args) { Dictionary }
|
144
|
-
code_inferior_or_equal(code_value)
|
145
|
-
when "<=>", "compare"
|
146
|
-
sig(args) { Dictionary }
|
147
|
-
code_compare(code_value)
|
148
|
-
when ">", "superior"
|
149
|
-
sig(args) { Dictionary }
|
150
|
-
code_superior(code_value)
|
151
|
-
when ">=", "superior_or_equal"
|
152
|
-
sig(args) { Dictionary }
|
153
|
-
code_superior_or_equal(code_value)
|
154
139
|
when "[]", "at", "get"
|
155
140
|
sig(args) { Object }
|
156
141
|
code_get(code_value)
|
@@ -605,11 +590,6 @@ class Code
|
|
605
590
|
self
|
606
591
|
end
|
607
592
|
|
608
|
-
def code_compare(other)
|
609
|
-
code_other = other.to_code
|
610
|
-
Integer.new(raw <=> code_other.raw)
|
611
|
-
end
|
612
|
-
|
613
593
|
def code_delete(*arguments, index: 0, **globals)
|
614
594
|
arguments = arguments.to_code.raw
|
615
595
|
code_index = index.to_code
|
@@ -808,16 +788,6 @@ class Code
|
|
808
788
|
Boolean.new(raw.value?(code_key))
|
809
789
|
end
|
810
790
|
|
811
|
-
def code_inferior(other)
|
812
|
-
code_other = other.to_code
|
813
|
-
Boolean.new(raw < code_other.raw)
|
814
|
-
end
|
815
|
-
|
816
|
-
def code_inferior_or_equal(other)
|
817
|
-
code_other = other.to_code
|
818
|
-
Boolean.new(raw <= code_other.raw)
|
819
|
-
end
|
820
|
-
|
821
791
|
def code_invert
|
822
792
|
Dictionary.new(raw.invert)
|
823
793
|
end
|
@@ -1007,16 +977,6 @@ class Code
|
|
1007
977
|
Integer.new(raw.size)
|
1008
978
|
end
|
1009
979
|
|
1010
|
-
def code_superior(other)
|
1011
|
-
code_other = other.to_code
|
1012
|
-
Boolean.new(raw > code_other.raw)
|
1013
|
-
end
|
1014
|
-
|
1015
|
-
def code_superior_or_equal(other)
|
1016
|
-
code_other = other.to_code
|
1017
|
-
Boolean.new(raw >= code_other.raw)
|
1018
|
-
end
|
1019
|
-
|
1020
980
|
def code_to_context
|
1021
981
|
Context.new(raw)
|
1022
982
|
end
|
data/lib/code/object/integer.rb
CHANGED
@@ -46,24 +46,9 @@ class Code
|
|
46
46
|
when "/", "division", "÷"
|
47
47
|
sig(args) { Integer | Decimal }
|
48
48
|
code_division(code_value)
|
49
|
-
when "<", "inferior"
|
50
|
-
sig(args) { Integer | Decimal }
|
51
|
-
code_inferior(code_value)
|
52
49
|
when "<<", "left_shift"
|
53
50
|
sig(args) { Integer | Decimal }
|
54
51
|
code_left_shift(code_value)
|
55
|
-
when "<=", "inferior_or_equal"
|
56
|
-
sig(args) { Integer | Decimal }
|
57
|
-
code_inferior_or_equal(code_value)
|
58
|
-
when "<=>", "compare"
|
59
|
-
sig(args) { Integer | Decimal }
|
60
|
-
code_compare(code_value)
|
61
|
-
when ">", "superior"
|
62
|
-
sig(args) { Integer | Decimal }
|
63
|
-
code_superior(code_value)
|
64
|
-
when ">=", "superior_or_equal"
|
65
|
-
sig(args) { Integer | Decimal }
|
66
|
-
code_superior_or_equal(code_value)
|
67
52
|
when ">>", "right_shift"
|
68
53
|
sig(args) { Integer | Decimal }
|
69
54
|
code_right_shift(code_value)
|
@@ -463,11 +448,6 @@ class Code
|
|
463
448
|
Integer.new(raw.ceil(code_n.raw))
|
464
449
|
end
|
465
450
|
|
466
|
-
def code_compare(other)
|
467
|
-
code_other = other.to_code
|
468
|
-
Integer.new(raw <=> code_other.raw)
|
469
|
-
end
|
470
|
-
|
471
451
|
def code_decrement!(n = nil)
|
472
452
|
code_n = n.to_code
|
473
453
|
code_n = Integer.new(1) if code_n.nothing?
|
@@ -509,16 +489,6 @@ class Code
|
|
509
489
|
Integer.new(raw + code_n.raw)
|
510
490
|
end
|
511
491
|
|
512
|
-
def code_inferior(other)
|
513
|
-
code_other = other.to_code
|
514
|
-
Boolean.new(raw < code_other.raw)
|
515
|
-
end
|
516
|
-
|
517
|
-
def code_inferior_or_equal(other)
|
518
|
-
code_other = other.to_code
|
519
|
-
Boolean.new(raw <= code_other.raw)
|
520
|
-
end
|
521
|
-
|
522
492
|
def code_left_shift(other)
|
523
493
|
code_other = other.to_code
|
524
494
|
Integer.new(raw << code_other.raw.to_i)
|
@@ -598,18 +568,6 @@ class Code
|
|
598
568
|
Decimal.new(Math.sqrt(raw).to_s)
|
599
569
|
end
|
600
570
|
|
601
|
-
def code_superior(other)
|
602
|
-
code_other = other.to_code
|
603
|
-
|
604
|
-
Boolean.new(raw > code_other.raw)
|
605
|
-
end
|
606
|
-
|
607
|
-
def code_superior_or_equal(other)
|
608
|
-
code_other = other.to_code
|
609
|
-
|
610
|
-
Boolean.new(raw >= code_other.raw)
|
611
|
-
end
|
612
|
-
|
613
571
|
def code_to_decimal
|
614
572
|
Decimal.new(raw)
|
615
573
|
end
|
data/lib/code/object/list.rb
CHANGED
@@ -137,8 +137,8 @@ class Code
|
|
137
137
|
sig(args) { String.maybe }
|
138
138
|
code_join(code_value)
|
139
139
|
when "sort"
|
140
|
-
sig(args)
|
141
|
-
code_sort
|
140
|
+
sig(args) { Function.maybe }
|
141
|
+
code_sort(code_value, **globals)
|
142
142
|
when "<<", "append"
|
143
143
|
sig(args) { Object }
|
144
144
|
code_append(code_value)
|
@@ -949,8 +949,24 @@ class Code
|
|
949
949
|
String.new(raw.join(code_separator.raw))
|
950
950
|
end
|
951
951
|
|
952
|
-
def code_sort
|
953
|
-
|
952
|
+
def code_sort(argument = nil, **globals)
|
953
|
+
code_argument = argument.to_code
|
954
|
+
|
955
|
+
List.new(
|
956
|
+
raw.sort_by.with_index do |code_element, index|
|
957
|
+
if code_argument.is_a?(Function)
|
958
|
+
code_argument
|
959
|
+
.call(
|
960
|
+
arguments: List.new([code_element, Integer.new(index), self]),
|
961
|
+
**globals
|
962
|
+
)
|
963
|
+
else
|
964
|
+
code_element
|
965
|
+
end
|
966
|
+
rescue Error::Next => e
|
967
|
+
e.code_value
|
968
|
+
end
|
969
|
+
)
|
954
970
|
end
|
955
971
|
|
956
972
|
def code_size
|
data/lib/code/object/range.rb
CHANGED
@@ -173,12 +173,12 @@ class Code
|
|
173
173
|
code_element = code_element.code_plus(code_argument)
|
174
174
|
|
175
175
|
if exclude_end?
|
176
|
-
while code_element.
|
176
|
+
while code_element.code_less(code_right).truthy?
|
177
177
|
code_list.code_append(code_element)
|
178
178
|
code_element = code_element.code_plus(code_argument)
|
179
179
|
end
|
180
180
|
else
|
181
|
-
while code_element.
|
181
|
+
while code_element.code_less_or_equal(code_right).truthy?
|
182
182
|
code_list.code_append(code_element)
|
183
183
|
code_element = code_element.code_plus(code_argument)
|
184
184
|
end
|