code-ruby 1.6.7 → 1.6.9
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/date.rb +72 -12
- 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
- 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: cba80b94b7452144afdc6db83185fea8fdb637cc2edf601d93fb5d7eb6b2f1a6
|
4
|
+
data.tar.gz: 8090a797c3a1060a69a1e3345bfd4219e743f5d37f1fe2bc9bb8acf18f75f36c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73f7d9564f81bf14888817c109eba0040b49ec4f6216cfc65bf80325ac0d8950a8288c767c708a8c015fd8698158f5d08985cb980125e51790716895312eb77f
|
7
|
+
data.tar.gz: '070169aa2528aacc5a18e9d9cf2a90add4ffa32d1c4f938aa5b0790ee2223ba98b4d1d2f07987bb1ea1fd533a29a35bae3632bb29e6a0fe7547647188efdbcc4'
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.9
|
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/date.rb
CHANGED
@@ -222,10 +222,15 @@ class Code
|
|
222
222
|
sig(args) do
|
223
223
|
{
|
224
224
|
year: (String | Integer).maybe,
|
225
|
+
years: (String | Integer).maybe,
|
225
226
|
month: (String | Integer).maybe,
|
227
|
+
months: (String | Integer).maybe,
|
226
228
|
day: (String | Integer).maybe,
|
229
|
+
days: (String | Integer).maybe,
|
227
230
|
week_day: (String | Integer).maybe,
|
228
|
-
|
231
|
+
week_days: (String | Integer).maybe,
|
232
|
+
week: (String | Integer).maybe,
|
233
|
+
weeks: (String | Integer).maybe
|
229
234
|
}
|
230
235
|
end
|
231
236
|
|
@@ -234,20 +239,30 @@ class Code
|
|
234
239
|
else
|
235
240
|
code_add(
|
236
241
|
year: code_value.code_get(:year),
|
242
|
+
years: code_value.code_get(:years),
|
237
243
|
month: code_value.code_get(:month),
|
244
|
+
months: code_value.code_get(:months),
|
238
245
|
day: code_value.code_get(:day),
|
246
|
+
days: code_value.code_get(:days),
|
239
247
|
week_day: code_value.code_get(:week_day),
|
240
|
-
|
248
|
+
week_days: code_value.code_get(:week_days),
|
249
|
+
week: code_value.code_get(:week),
|
250
|
+
weeks: code_value.code_get(:weeks)
|
241
251
|
)
|
242
252
|
end
|
243
253
|
when "substract"
|
244
254
|
sig(args) do
|
245
255
|
{
|
246
256
|
year: (String | Integer).maybe,
|
257
|
+
years: (String | Integer).maybe,
|
247
258
|
month: (String | Integer).maybe,
|
259
|
+
months: (String | Integer).maybe,
|
248
260
|
day: (String | Integer).maybe,
|
261
|
+
days: (String | Integer).maybe,
|
249
262
|
week_day: (String | Integer).maybe,
|
250
|
-
|
263
|
+
week_days: (String | Integer).maybe,
|
264
|
+
week: (String | Integer).maybe,
|
265
|
+
weeks: (String | Integer).maybe
|
251
266
|
}
|
252
267
|
end
|
253
268
|
|
@@ -256,20 +271,30 @@ class Code
|
|
256
271
|
else
|
257
272
|
code_substract(
|
258
273
|
year: code_value.code_get(:year),
|
274
|
+
years: code_value.code_get(:years),
|
259
275
|
month: code_value.code_get(:month),
|
276
|
+
months: code_value.code_get(:months),
|
260
277
|
day: code_value.code_get(:day),
|
278
|
+
days: code_value.code_get(:days),
|
261
279
|
week_day: code_value.code_get(:week_day),
|
262
|
-
|
280
|
+
week_days: code_value.code_get(:week_days),
|
281
|
+
week: code_value.code_get(:week),
|
282
|
+
weeks: code_value.code_get(:weeks)
|
263
283
|
)
|
264
284
|
end
|
265
285
|
when "change"
|
266
286
|
sig(args) do
|
267
287
|
{
|
268
288
|
year: (String | Integer).maybe,
|
289
|
+
years: (String | Integer).maybe,
|
269
290
|
month: (String | Integer).maybe,
|
291
|
+
months: (String | Integer).maybe,
|
270
292
|
day: (String | Integer).maybe,
|
293
|
+
days: (String | Integer).maybe,
|
271
294
|
week_day: (String | Integer).maybe,
|
272
|
-
|
295
|
+
week_days: (String | Integer).maybe,
|
296
|
+
week: (String | Integer).maybe,
|
297
|
+
weeks: (String | Integer).maybe
|
273
298
|
}
|
274
299
|
end
|
275
300
|
|
@@ -278,10 +303,15 @@ class Code
|
|
278
303
|
else
|
279
304
|
code_change(
|
280
305
|
year: code_value.code_get(:year),
|
306
|
+
years: code_value.code_get(:years),
|
281
307
|
month: code_value.code_get(:month),
|
308
|
+
months: code_value.code_get(:months),
|
282
309
|
day: code_value.code_get(:day),
|
310
|
+
days: code_value.code_get(:days),
|
283
311
|
week_day: code_value.code_get(:week_day),
|
284
|
-
|
312
|
+
week_days: code_value.code_get(:week_days),
|
313
|
+
week: code_value.code_get(:week),
|
314
|
+
weeks: code_value.code_get(:weeks)
|
285
315
|
)
|
286
316
|
end
|
287
317
|
else
|
@@ -419,10 +449,15 @@ class Code
|
|
419
449
|
sig(args) do
|
420
450
|
{
|
421
451
|
year: (String | Integer).maybe,
|
452
|
+
years: (String | Integer).maybe,
|
422
453
|
month: (String | Integer).maybe,
|
454
|
+
months: (String | Integer).maybe,
|
423
455
|
day: (String | Integer).maybe,
|
456
|
+
days: (String | Integer).maybe,
|
424
457
|
week_day: (String | Integer).maybe,
|
425
|
-
|
458
|
+
week_days: (String | Integer).maybe,
|
459
|
+
week: (String | Integer).maybe,
|
460
|
+
weeks: (String | Integer).maybe
|
426
461
|
}
|
427
462
|
end
|
428
463
|
|
@@ -431,20 +466,30 @@ class Code
|
|
431
466
|
else
|
432
467
|
code_add(
|
433
468
|
year: code_value.code_get(:year),
|
469
|
+
years: code_value.code_get(:years),
|
434
470
|
month: code_value.code_get(:month),
|
471
|
+
months: code_value.code_get(:months),
|
435
472
|
day: code_value.code_get(:day),
|
473
|
+
days: code_value.code_get(:days),
|
436
474
|
week_day: code_value.code_get(:week_day),
|
437
|
-
|
475
|
+
week_days: code_value.code_get(:week_days),
|
476
|
+
week: code_value.code_get(:week),
|
477
|
+
weeks: code_value.code_get(:weeks)
|
438
478
|
)
|
439
479
|
end
|
440
480
|
when "substract"
|
441
481
|
sig(args) do
|
442
482
|
{
|
443
483
|
year: (String | Integer).maybe,
|
484
|
+
years: (String | Integer).maybe,
|
444
485
|
month: (String | Integer).maybe,
|
486
|
+
months: (String | Integer).maybe,
|
445
487
|
day: (String | Integer).maybe,
|
488
|
+
days: (String | Integer).maybe,
|
446
489
|
week_day: (String | Integer).maybe,
|
447
|
-
|
490
|
+
week_days: (String | Integer).maybe,
|
491
|
+
week: (String | Integer).maybe,
|
492
|
+
weeks: (String | Integer).maybe
|
448
493
|
}
|
449
494
|
end
|
450
495
|
|
@@ -453,20 +498,30 @@ class Code
|
|
453
498
|
else
|
454
499
|
code_substract(
|
455
500
|
year: code_value.code_get(:year),
|
501
|
+
years: code_value.code_get(:years),
|
456
502
|
month: code_value.code_get(:month),
|
503
|
+
months: code_value.code_get(:months),
|
457
504
|
day: code_value.code_get(:day),
|
505
|
+
days: code_value.code_get(:days),
|
458
506
|
week_day: code_value.code_get(:week_day),
|
459
|
-
|
507
|
+
week_days: code_value.code_get(:week_days),
|
508
|
+
week: code_value.code_get(:week),
|
509
|
+
weeks: code_value.code_get(:weeks)
|
460
510
|
)
|
461
511
|
end
|
462
512
|
when "change"
|
463
513
|
sig(args) do
|
464
514
|
{
|
465
515
|
year: (String | Integer).maybe,
|
516
|
+
years: (String | Integer).maybe,
|
466
517
|
month: (String | Integer).maybe,
|
518
|
+
months: (String | Integer).maybe,
|
467
519
|
day: (String | Integer).maybe,
|
520
|
+
days: (String | Integer).maybe,
|
468
521
|
week_day: (String | Integer).maybe,
|
469
|
-
|
522
|
+
week_days: (String | Integer).maybe,
|
523
|
+
week: (String | Integer).maybe,
|
524
|
+
weeks: (String | Integer).maybe
|
470
525
|
}
|
471
526
|
end
|
472
527
|
|
@@ -475,10 +530,15 @@ class Code
|
|
475
530
|
else
|
476
531
|
code_change(
|
477
532
|
year: code_value.code_get(:year),
|
533
|
+
years: code_value.code_get(:years),
|
478
534
|
month: code_value.code_get(:month),
|
535
|
+
months: code_value.code_get(:months),
|
479
536
|
day: code_value.code_get(:day),
|
537
|
+
days: code_value.code_get(:days),
|
480
538
|
week_day: code_value.code_get(:week_day),
|
481
|
-
|
539
|
+
week_days: code_value.code_get(:week_days),
|
540
|
+
week: code_value.code_get(:week),
|
541
|
+
weeks: code_value.code_get(:weeks)
|
482
542
|
)
|
483
543
|
end
|
484
544
|
else
|
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
|