code-ruby 3.1.2 → 4.0.1

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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/code +100 -20
  4. data/lib/code/concerns/shared.rb +335 -15
  5. data/lib/code/format.rb +33 -15
  6. data/lib/code/network.rb +82 -0
  7. data/lib/code/node/call.rb +80 -2
  8. data/lib/code/node/call_argument.rb +14 -0
  9. data/lib/code/node/code.rb +4 -3
  10. data/lib/code/node/function_parameter.rb +7 -4
  11. data/lib/code/node/list.rb +32 -2
  12. data/lib/code/node/square_bracket.rb +4 -2
  13. data/lib/code/object/base_64.rb +132 -6
  14. data/lib/code/object/boolean.rb +56 -0
  15. data/lib/code/object/class.rb +143 -2
  16. data/lib/code/object/code.rb +108 -7
  17. data/lib/code/object/context.rb +59 -1
  18. data/lib/code/object/cryptography.rb +69 -0
  19. data/lib/code/object/date.rb +13800 -462
  20. data/lib/code/object/decimal.rb +1098 -0
  21. data/lib/code/object/dictionary.rb +1861 -11
  22. data/lib/code/object/duration.rb +24 -0
  23. data/lib/code/object/function.rb +289 -27
  24. data/lib/code/object/global.rb +447 -1
  25. data/lib/code/object/html.rb +181 -7
  26. data/lib/code/object/http.rb +253 -17
  27. data/lib/code/object/ics.rb +76 -13
  28. data/lib/code/object/identifier_list.rb +30 -10
  29. data/lib/code/object/integer.rb +1265 -2
  30. data/lib/code/object/json.rb +80 -1
  31. data/lib/code/object/list.rb +3371 -10
  32. data/lib/code/object/nothing.rb +53 -0
  33. data/lib/code/object/number.rb +120 -0
  34. data/lib/code/object/parameter.rb +149 -0
  35. data/lib/code/object/range.rb +530 -14
  36. data/lib/code/object/smtp.rb +103 -12
  37. data/lib/code/object/string.rb +968 -3
  38. data/lib/code/object/super.rb +11 -1
  39. data/lib/code/object/time.rb +13932 -498
  40. data/lib/code/object/url.rb +67 -0
  41. data/lib/code/object.rb +582 -0
  42. data/lib/code/parser.rb +194 -55
  43. data/lib/code-ruby.rb +3 -0
  44. data/lib/code.rb +30 -3
  45. metadata +135 -84
  46. data/.github/dependabot.yml +0 -15
  47. data/.github/workflows/ci.yml +0 -38
  48. data/.gitignore +0 -30
  49. data/.node-version +0 -1
  50. data/.npm-version +0 -1
  51. data/.prettierignore +0 -2
  52. data/.rspec +0 -1
  53. data/.rubocop.yml +0 -140
  54. data/.ruby-version +0 -1
  55. data/.tool-versions +0 -3
  56. data/AGENTS.md +0 -43
  57. data/Gemfile +0 -22
  58. data/Gemfile.lock +0 -292
  59. data/Rakefile +0 -5
  60. data/bin/bundle +0 -123
  61. data/bin/bundle-audit +0 -31
  62. data/bin/bundler-audit +0 -31
  63. data/bin/dorian +0 -31
  64. data/bin/rspec +0 -31
  65. data/bin/rubocop +0 -31
  66. data/bin/test +0 -5
  67. data/code-ruby.gemspec +0 -34
  68. data/docs/precedence.txt +0 -36
  69. data/package-lock.json +0 -14
  70. data/package.json +0 -7
  71. data/spec/bin/code_spec.rb +0 -48
  72. data/spec/code/format_spec.rb +0 -153
  73. data/spec/code/node/call_spec.rb +0 -11
  74. data/spec/code/object/boolean_spec.rb +0 -18
  75. data/spec/code/object/cryptography_spec.rb +0 -25
  76. data/spec/code/object/decimal_spec.rb +0 -50
  77. data/spec/code/object/dictionary_spec.rb +0 -98
  78. data/spec/code/object/function_spec.rb +0 -268
  79. data/spec/code/object/http_spec.rb +0 -33
  80. data/spec/code/object/ics_spec.rb +0 -50
  81. data/spec/code/object/integer_spec.rb +0 -42
  82. data/spec/code/object/list_spec.rb +0 -22
  83. data/spec/code/object/nothing_spec.rb +0 -14
  84. data/spec/code/object/range_spec.rb +0 -23
  85. data/spec/code/object/string_spec.rb +0 -26
  86. data/spec/code/parser/boolean_spec.rb +0 -11
  87. data/spec/code/parser/chained_call_spec.rb +0 -16
  88. data/spec/code/parser/dictionary_spec.rb +0 -18
  89. data/spec/code/parser/function_spec.rb +0 -16
  90. data/spec/code/parser/group_spec.rb +0 -11
  91. data/spec/code/parser/if_modifier_spec.rb +0 -18
  92. data/spec/code/parser/list_spec.rb +0 -17
  93. data/spec/code/parser/number_spec.rb +0 -11
  94. data/spec/code/parser/string_spec.rb +0 -20
  95. data/spec/code/parser_spec.rb +0 -52
  96. data/spec/code/type_spec.rb +0 -21
  97. data/spec/code_spec.rb +0 -717
  98. data/spec/spec_helper.rb +0 -21
  99. data/spec/zeitwerk/loader_spec.rb +0 -7
@@ -3,6 +3,924 @@
3
3
  class Code
4
4
  class Object
5
5
  class Decimal < Number
6
+ CLASS_DOCUMENTATION = {
7
+ name: "Decimal",
8
+ description:
9
+ "represents fractional numbers with arithmetic, rounding, formatting, duration helpers, and numeric predicates.",
10
+ examples: ["Decimal.new(1.5)", "Decimal.new(\"2.5\") + 1", "1.5.days"]
11
+ }.freeze
12
+ INSTANCE_FUNCTIONS = {
13
+ "%" => {
14
+ name: "%",
15
+ description: "returns the decimal modulo another number.",
16
+ examples: ["5.5 % 2", "4.0 % 2", "7.5 % 3"]
17
+ },
18
+ "modulo" => {
19
+ name: "modulo",
20
+ description: "returns the decimal modulo another number.",
21
+ examples: %w[5.5.modulo(2) 4.0.modulo(2) 7.5.modulo(3)]
22
+ },
23
+ "&" => {
24
+ name: "&",
25
+ description:
26
+ "returns the bitwise and of the decimal integer value and another number.",
27
+ examples: ["5.5 & 3", "4.0 & 1", "7.0 & 2"]
28
+ },
29
+ "bitwise_and" => {
30
+ name: "bitwise_and",
31
+ description:
32
+ "returns the bitwise and of the decimal integer value and another number.",
33
+ examples: %w[5.5.bitwise_and(3) 4.0.bitwise_and(1) 7.0.bitwise_and(2)]
34
+ },
35
+ "*" => {
36
+ name: "*",
37
+ description: "returns the decimal multiplied by another number.",
38
+ examples: ["2.5 * 2", "1.5 * 3", "4.0 * 2"]
39
+ },
40
+ "multiplication" => {
41
+ name: "multiplication",
42
+ description: "returns the decimal multiplied by another number.",
43
+ examples: %w[
44
+ 2.5.multiplication(2)
45
+ 1.5.multiplication(3)
46
+ 4.0.multiplication(2)
47
+ ]
48
+ },
49
+ "**" => {
50
+ name: "**",
51
+ description: "returns the decimal raised to a power.",
52
+ examples: ["2.5 ** 2", "4.0 ** 2", "9.0 ** 0.5"]
53
+ },
54
+ "power" => {
55
+ name: "power",
56
+ description: "returns the decimal raised to a power.",
57
+ examples: %w[2.5.power(2) 4.0.power(2) 9.0.power(0.5)]
58
+ },
59
+ "+" => {
60
+ name: "+",
61
+ description:
62
+ "returns the decimal itself when unary, adds numbers, or joins other values as text.",
63
+ examples: ["1.5 + 2", "1.5 + 2.5", "+1.5"]
64
+ },
65
+ "plus" => {
66
+ name: "plus",
67
+ description: "adds numbers or joins non-numeric values as text.",
68
+ examples: %w[1.5.plus(2) 1.5.plus(2.5) 1.5.plus(:x)]
69
+ },
70
+ "-" => {
71
+ name: "-",
72
+ description:
73
+ "returns the decimal negated when unary or minus another number.",
74
+ examples: ["5.5 - 1", "5.5 - 2.5", "-5.5"]
75
+ },
76
+ "minus" => {
77
+ name: "minus",
78
+ description: "returns the decimal minus another number.",
79
+ examples: %w[5.5.minus(1) 5.5.minus(2.5) 1.5.minus(3)]
80
+ },
81
+ "/" => {
82
+ name: "/",
83
+ description: "returns the decimal divided by another number.",
84
+ examples: ["5.5 / 2", "4.0 / 2", "7.5 / 3"]
85
+ },
86
+ "division" => {
87
+ name: "division",
88
+ description: "returns the decimal divided by another number.",
89
+ examples: %w[5.5.division(2) 4.0.division(2) 7.5.division(3)]
90
+ },
91
+ "decimal_divide" => {
92
+ name: "decimal_divide",
93
+ description: "returns the decimal divided by another number.",
94
+ examples: %w[
95
+ 5.5.decimal_divide(2)
96
+ 4.0.decimal_divide(2)
97
+ 7.5.decimal_divide(3)
98
+ ]
99
+ },
100
+ "<<" => {
101
+ name: "<<",
102
+ description: "returns the decimal integer value shifted left.",
103
+ examples: ["5.5 << 1", "4.0 << 2", "1.0 << 3"]
104
+ },
105
+ "left_shift" => {
106
+ name: "left_shift",
107
+ description: "returns the decimal integer value shifted left.",
108
+ examples: %w[5.5.left_shift(1) 4.0.left_shift(2) 1.0.left_shift(3)]
109
+ },
110
+ ">>" => {
111
+ name: ">>",
112
+ description: "returns the decimal integer value shifted right.",
113
+ examples: ["5.5 >> 1", "4.0 >> 1", "8.0 >> 2"]
114
+ },
115
+ "right_shift" => {
116
+ name: "right_shift",
117
+ description: "returns the decimal integer value shifted right.",
118
+ examples: %w[5.5.right_shift(1) 4.0.right_shift(1) 8.0.right_shift(2)]
119
+ },
120
+ "^" => {
121
+ name: "^",
122
+ description:
123
+ "returns the bitwise xor of the decimal integer value and another number.",
124
+ examples: ["5.5 ^ 3", "4.0 ^ 1", "7.0 ^ 2"]
125
+ },
126
+ "bitwise_xor" => {
127
+ name: "bitwise_xor",
128
+ description:
129
+ "returns the bitwise xor of the decimal integer value and another number.",
130
+ examples: %w[5.5.bitwise_xor(3) 4.0.bitwise_xor(1) 7.0.bitwise_xor(2)]
131
+ },
132
+ "abs" => {
133
+ name: "abs",
134
+ description: "returns the absolute value of the decimal.",
135
+ examples: %w[-1.5.abs 1.5.abs 0.0.abs]
136
+ },
137
+ "between?" => {
138
+ name: "between?",
139
+ description: "returns whether the decimal is between two bounds.",
140
+ examples: [
141
+ "1.5.between?(1, 2)",
142
+ "3.5.between?(1, 2)",
143
+ "2.0.between?(1.5, 2.5)"
144
+ ]
145
+ },
146
+ "clamp" => {
147
+ name: "clamp",
148
+ description: "returns the decimal constrained between two bounds.",
149
+ examples: ["5.5.clamp(1, 3)", "0.5.clamp(1, 3)", "2.5.clamp(1, 3)"]
150
+ },
151
+ "divide" => {
152
+ name: "divide",
153
+ description:
154
+ "returns integer division of the decimal by another number.",
155
+ examples: %w[5.5.divide(2) 10.5.divide(3) 9.5.divide(2)]
156
+ },
157
+ "divide_modulo" => {
158
+ name: "divide_modulo",
159
+ description: "returns integer division and modulo as a list.",
160
+ examples: %w[
161
+ 5.5.divide_modulo(2)
162
+ 10.5.divide_modulo(3)
163
+ 9.5.divide_modulo(2)
164
+ ]
165
+ },
166
+ "ceil" => {
167
+ name: "ceil",
168
+ description: "returns the decimal rounded up.",
169
+ examples: %w[1.2.ceil 1.234.ceil(2) -1.2.ceil]
170
+ },
171
+ "day" => {
172
+ name: "day",
173
+ description: "returns a duration of this many days.",
174
+ examples: %w[1.5.day 2.0.day 0.5.day]
175
+ },
176
+ "days" => {
177
+ name: "days",
178
+ description: "returns a duration of this many days.",
179
+ examples: %w[1.5.days 2.0.days 0.5.days]
180
+ },
181
+ "floor" => {
182
+ name: "floor",
183
+ description: "returns the decimal rounded down.",
184
+ examples: %w[1.8.floor 1.234.floor(2) -1.2.floor]
185
+ },
186
+ "hour" => {
187
+ name: "hour",
188
+ description: "returns a duration of this many hours.",
189
+ examples: %w[1.5.hour 2.0.hour 0.5.hour]
190
+ },
191
+ "hours" => {
192
+ name: "hours",
193
+ description: "returns a duration of this many hours.",
194
+ examples: %w[1.5.hours 2.0.hours 0.5.hours]
195
+ },
196
+ "minute" => {
197
+ name: "minute",
198
+ description: "returns a duration of this many minutes.",
199
+ examples: %w[1.5.minute 2.0.minute 0.5.minute]
200
+ },
201
+ "minutes" => {
202
+ name: "minutes",
203
+ description: "returns a duration of this many minutes.",
204
+ examples: %w[1.5.minutes 2.0.minutes 0.5.minutes]
205
+ },
206
+ "month" => {
207
+ name: "month",
208
+ description: "returns a duration of this many months.",
209
+ examples: %w[1.5.month 2.0.month 0.5.month]
210
+ },
211
+ "months" => {
212
+ name: "months",
213
+ description: "returns a duration of this many months.",
214
+ examples: %w[1.5.months 2.0.months 0.5.months]
215
+ },
216
+ "next_decimal" => {
217
+ name: "next_decimal",
218
+ description: "alias for next.",
219
+ examples: %w[1.5.next_decimal 0.0.next_decimal -1.5.next_decimal]
220
+ },
221
+ "previous_decimal" => {
222
+ name: "previous_decimal",
223
+ description: "alias for previous.",
224
+ examples: %w[
225
+ 1.5.previous_decimal
226
+ 0.0.previous_decimal
227
+ -1.5.previous_decimal
228
+ ]
229
+ },
230
+ "round" => {
231
+ name: "round",
232
+ description: "returns the decimal rounded to a precision.",
233
+ examples: %w[1.5.round 1.234.round(2) -1.5.round]
234
+ },
235
+ "second" => {
236
+ name: "second",
237
+ description: "returns a duration of this many seconds.",
238
+ examples: %w[1.5.second 2.0.second 0.5.second]
239
+ },
240
+ "seconds" => {
241
+ name: "seconds",
242
+ description: "returns a duration of this many seconds.",
243
+ examples: %w[1.5.seconds 2.0.seconds 0.5.seconds]
244
+ },
245
+ "sqrt" => {
246
+ name: "sqrt",
247
+ description: "returns the square root of the decimal.",
248
+ examples: %w[4.0.sqrt 9.0.sqrt 2.25.sqrt]
249
+ },
250
+ "truncate" => {
251
+ name: "truncate",
252
+ description: "returns the decimal truncated to a precision.",
253
+ examples: %w[1.9.truncate 1.234.truncate(2) -1.9.truncate]
254
+ },
255
+ "to_fixed" => {
256
+ name: "to_fixed",
257
+ description:
258
+ "returns the decimal formatted with a fixed number of fractional digits.",
259
+ examples: %w[1.5.to_fixed 1.5.to_fixed(2) 1.234.to_fixed(1)]
260
+ },
261
+ "to_precision" => {
262
+ name: "to_precision",
263
+ description:
264
+ "returns the decimal formatted with a fixed number of significant digits.",
265
+ examples: %w[
266
+ 1.5.to_precision
267
+ 1.234.to_precision(2)
268
+ 123.4.to_precision(3)
269
+ ]
270
+ },
271
+ "to_exponential" => {
272
+ name: "to_exponential",
273
+ description:
274
+ "returns the decimal formatted with exponential notation.",
275
+ examples: %w[
276
+ 1.5.to_exponential
277
+ 1.5.to_exponential(2)
278
+ 123.4.to_exponential(1)
279
+ ]
280
+ },
281
+ "week" => {
282
+ name: "week",
283
+ description: "returns a duration of this many weeks.",
284
+ examples: %w[1.5.week 2.0.week 0.5.week]
285
+ },
286
+ "weeks" => {
287
+ name: "weeks",
288
+ description: "returns a duration of this many weeks.",
289
+ examples: %w[1.5.weeks 2.0.weeks 0.5.weeks]
290
+ },
291
+ "year" => {
292
+ name: "year",
293
+ description: "returns a duration of this many years.",
294
+ examples: %w[1.5.year 2.0.year 0.5.year]
295
+ },
296
+ "years" => {
297
+ name: "years",
298
+ description: "returns a duration of this many years.",
299
+ examples: %w[1.5.years 2.0.years 0.5.years]
300
+ },
301
+ "|" => {
302
+ name: "|",
303
+ description:
304
+ "returns the bitwise or of the decimal integer value and another number.",
305
+ examples: ["5.5 | 2", "4.0 | 1", "7.0 | 2"]
306
+ },
307
+ "bitwise_or" => {
308
+ name: "bitwise_or",
309
+ description:
310
+ "returns the bitwise or of the decimal integer value and another number.",
311
+ examples: %w[5.5.bitwise_or(2) 4.0.bitwise_or(1) 7.0.bitwise_or(2)]
312
+ },
313
+ "many?" => {
314
+ name: "many?",
315
+ description: "returns whether the decimal is greater than one.",
316
+ examples: %w[2.0.many? 1.0.many? 0.5.many?]
317
+ },
318
+ "any?" => {
319
+ name: "any?",
320
+ description: "returns whether the decimal is positive.",
321
+ examples: %w[1.0.any? 0.0.any? -1.0.any?]
322
+ },
323
+ "positive?" => {
324
+ name: "positive?",
325
+ description: "returns whether the decimal is positive.",
326
+ examples: %w[1.0.positive? 0.0.positive? -1.0.positive?]
327
+ },
328
+ "negative?" => {
329
+ name: "negative?",
330
+ description: "returns whether the decimal is negative.",
331
+ examples: %w[-1.0.negative? 0.0.negative? 1.0.negative?]
332
+ },
333
+ "next" => {
334
+ name: "next",
335
+ description: "returns the decimal plus one.",
336
+ examples: %w[1.5.next 0.0.next -1.5.next]
337
+ },
338
+ "successor" => {
339
+ name: "successor",
340
+ description: "alias for next.",
341
+ examples: %w[1.5.successor 0.0.successor -1.5.successor]
342
+ },
343
+ "previous" => {
344
+ name: "previous",
345
+ description: "returns the decimal minus one.",
346
+ examples: %w[1.5.previous 0.0.previous -1.5.previous]
347
+ },
348
+ "predecessor" => {
349
+ name: "predecessor",
350
+ description: "alias for previous.",
351
+ examples: %w[1.5.predecessor 0.0.predecessor -1.5.predecessor]
352
+ },
353
+ "remainder" => {
354
+ name: "remainder",
355
+ description:
356
+ "returns the remainder after division by another number.",
357
+ examples: %w[5.5.remainder(2) 10.5.remainder(3) 9.5.remainder(2)]
358
+ },
359
+ "non_zero?" => {
360
+ name: "non_zero?",
361
+ description: "returns whether the decimal is not zero.",
362
+ examples: %w[1.0.non_zero? 0.0.non_zero? -1.0.non_zero?]
363
+ },
364
+ "integer?" => {
365
+ name: "integer?",
366
+ description: "returns whether the decimal has no fractional part.",
367
+ examples: %w[1.0.integer? 1.5.integer? 0.0.integer?]
368
+ },
369
+ "finite?" => {
370
+ name: "finite?",
371
+ description: "returns whether the decimal is finite.",
372
+ examples: %w[1.0.finite? 0.0.finite? -1.0.finite?]
373
+ },
374
+ "infinite?" => {
375
+ name: "infinite?",
376
+ description: "returns whether the decimal is infinite.",
377
+ examples: %w[1.0.infinite? 0.0.infinite? -1.0.infinite?]
378
+ },
379
+ "not_a_number?" => {
380
+ name: "not_a_number?",
381
+ description: "returns whether the decimal is not a number.",
382
+ examples: %w[1.0.not_a_number? 0.0.not_a_number? -1.0.not_a_number?]
383
+ },
384
+ "numerator" => {
385
+ name: "numerator",
386
+ description: "returns the decimal numerator.",
387
+ examples: %w[1.5.numerator 2.0.numerator 0.5.numerator]
388
+ },
389
+ "denominator" => {
390
+ name: "denominator",
391
+ description: "returns the decimal denominator.",
392
+ examples: %w[1.5.denominator 2.0.denominator 0.5.denominator]
393
+ },
394
+ "magnitude" => {
395
+ name: "magnitude",
396
+ description: "returns the absolute value of the decimal.",
397
+ examples: %w[-1.5.magnitude 1.5.magnitude 0.0.magnitude]
398
+ },
399
+ "zero?" => {
400
+ name: "zero?",
401
+ description: "returns whether the decimal is zero.",
402
+ examples: %w[0.0.zero? 1.0.zero? 0.5.zero?]
403
+ },
404
+ "one?" => {
405
+ name: "one?",
406
+ description: "returns whether the decimal is one.",
407
+ examples: %w[1.0.one? 2.0.one? 0.5.one?]
408
+ },
409
+ "two?" => {
410
+ name: "two?",
411
+ description: "returns whether the decimal is two.",
412
+ examples: %w[2.0.two? 3.0.two? 0.5.two?]
413
+ },
414
+ "three?" => {
415
+ name: "three?",
416
+ description: "returns whether the decimal is three.",
417
+ examples: %w[3.0.three? 4.0.three? 0.5.three?]
418
+ },
419
+ "four?" => {
420
+ name: "four?",
421
+ description: "returns whether the decimal is four.",
422
+ examples: %w[4.0.four? 5.0.four? 0.5.four?]
423
+ },
424
+ "five?" => {
425
+ name: "five?",
426
+ description: "returns whether the decimal is five.",
427
+ examples: %w[5.0.five? 6.0.five? 0.5.five?]
428
+ },
429
+ "six?" => {
430
+ name: "six?",
431
+ description: "returns whether the decimal is six.",
432
+ examples: %w[6.0.six? 7.0.six? 0.5.six?]
433
+ },
434
+ "seven?" => {
435
+ name: "seven?",
436
+ description: "returns whether the decimal is seven.",
437
+ examples: %w[7.0.seven? 8.0.seven? 0.5.seven?]
438
+ },
439
+ "eight?" => {
440
+ name: "eight?",
441
+ description: "returns whether the decimal is eight.",
442
+ examples: %w[8.0.eight? 9.0.eight? 0.5.eight?]
443
+ },
444
+ "nine?" => {
445
+ name: "nine?",
446
+ description: "returns whether the decimal is nine.",
447
+ examples: %w[9.0.nine? 10.0.nine? 0.5.nine?]
448
+ },
449
+ "ten?" => {
450
+ name: "ten?",
451
+ description: "returns whether the decimal is ten.",
452
+ examples: %w[10.0.ten? 11.0.ten? 0.5.ten?]
453
+ },
454
+ "eleven?" => {
455
+ name: "eleven?",
456
+ description: "returns whether the decimal is eleven.",
457
+ examples: %w[11.0.eleven? 12.0.eleven? 0.5.eleven?]
458
+ },
459
+ "twelve?" => {
460
+ name: "twelve?",
461
+ description: "returns whether the decimal is twelve.",
462
+ examples: %w[12.0.twelve? 13.0.twelve? 0.5.twelve?]
463
+ },
464
+ "thirteen?" => {
465
+ name: "thirteen?",
466
+ description: "returns whether the decimal is thirteen.",
467
+ examples: %w[13.0.thirteen? 14.0.thirteen? 0.5.thirteen?]
468
+ },
469
+ "fourteen?" => {
470
+ name: "fourteen?",
471
+ description: "returns whether the decimal is fourteen.",
472
+ examples: %w[14.0.fourteen? 15.0.fourteen? 0.5.fourteen?]
473
+ },
474
+ "fifteen?" => {
475
+ name: "fifteen?",
476
+ description: "returns whether the decimal is fifteen.",
477
+ examples: %w[15.0.fifteen? 16.0.fifteen? 0.5.fifteen?]
478
+ },
479
+ "sixteen?" => {
480
+ name: "sixteen?",
481
+ description: "returns whether the decimal is sixteen.",
482
+ examples: %w[16.0.sixteen? 17.0.sixteen? 0.5.sixteen?]
483
+ },
484
+ "seventeen?" => {
485
+ name: "seventeen?",
486
+ description: "returns whether the decimal is seventeen.",
487
+ examples: %w[17.0.seventeen? 18.0.seventeen? 0.5.seventeen?]
488
+ },
489
+ "eighteen?" => {
490
+ name: "eighteen?",
491
+ description: "returns whether the decimal is eighteen.",
492
+ examples: %w[18.0.eighteen? 19.0.eighteen? 0.5.eighteen?]
493
+ },
494
+ "nineteen?" => {
495
+ name: "nineteen?",
496
+ description: "returns whether the decimal is nineteen.",
497
+ examples: %w[19.0.nineteen? 20.0.nineteen? 0.5.nineteen?]
498
+ },
499
+ "twenty?" => {
500
+ name: "twenty?",
501
+ description: "returns whether the decimal is twenty.",
502
+ examples: %w[20.0.twenty? 21.0.twenty? 0.5.twenty?]
503
+ },
504
+ "twenty_one?" => {
505
+ name: "twenty_one?",
506
+ description: "returns whether the decimal is twenty one.",
507
+ examples: %w[21.0.twenty_one? 22.0.twenty_one? 0.5.twenty_one?]
508
+ },
509
+ "twenty_two?" => {
510
+ name: "twenty_two?",
511
+ description: "returns whether the decimal is twenty two.",
512
+ examples: %w[22.0.twenty_two? 23.0.twenty_two? 0.5.twenty_two?]
513
+ },
514
+ "twenty_three?" => {
515
+ name: "twenty_three?",
516
+ description: "returns whether the decimal is twenty three.",
517
+ examples: %w[23.0.twenty_three? 24.0.twenty_three? 0.5.twenty_three?]
518
+ },
519
+ "twenty_four?" => {
520
+ name: "twenty_four?",
521
+ description: "returns whether the decimal is twenty four.",
522
+ examples: %w[24.0.twenty_four? 25.0.twenty_four? 0.5.twenty_four?]
523
+ },
524
+ "twenty_five?" => {
525
+ name: "twenty_five?",
526
+ description: "returns whether the decimal is twenty five.",
527
+ examples: %w[25.0.twenty_five? 26.0.twenty_five? 0.5.twenty_five?]
528
+ },
529
+ "twenty_six?" => {
530
+ name: "twenty_six?",
531
+ description: "returns whether the decimal is twenty six.",
532
+ examples: %w[26.0.twenty_six? 27.0.twenty_six? 0.5.twenty_six?]
533
+ },
534
+ "twenty_seven?" => {
535
+ name: "twenty_seven?",
536
+ description: "returns whether the decimal is twenty seven.",
537
+ examples: %w[27.0.twenty_seven? 28.0.twenty_seven? 0.5.twenty_seven?]
538
+ },
539
+ "twenty_eight?" => {
540
+ name: "twenty_eight?",
541
+ description: "returns whether the decimal is twenty eight.",
542
+ examples: %w[28.0.twenty_eight? 29.0.twenty_eight? 0.5.twenty_eight?]
543
+ },
544
+ "twenty_nine?" => {
545
+ name: "twenty_nine?",
546
+ description: "returns whether the decimal is twenty nine.",
547
+ examples: %w[29.0.twenty_nine? 30.0.twenty_nine? 0.5.twenty_nine?]
548
+ },
549
+ "thirty?" => {
550
+ name: "thirty?",
551
+ description: "returns whether the decimal is thirty.",
552
+ examples: %w[30.0.thirty? 31.0.thirty? 0.5.thirty?]
553
+ },
554
+ "thirty_one?" => {
555
+ name: "thirty_one?",
556
+ description: "returns whether the decimal is thirty one.",
557
+ examples: %w[31.0.thirty_one? 32.0.thirty_one? 0.5.thirty_one?]
558
+ },
559
+ "thirty_two?" => {
560
+ name: "thirty_two?",
561
+ description: "returns whether the decimal is thirty two.",
562
+ examples: %w[32.0.thirty_two? 33.0.thirty_two? 0.5.thirty_two?]
563
+ },
564
+ "thirty_three?" => {
565
+ name: "thirty_three?",
566
+ description: "returns whether the decimal is thirty three.",
567
+ examples: %w[33.0.thirty_three? 34.0.thirty_three? 0.5.thirty_three?]
568
+ },
569
+ "thirty_four?" => {
570
+ name: "thirty_four?",
571
+ description: "returns whether the decimal is thirty four.",
572
+ examples: %w[34.0.thirty_four? 35.0.thirty_four? 0.5.thirty_four?]
573
+ },
574
+ "thirty_five?" => {
575
+ name: "thirty_five?",
576
+ description: "returns whether the decimal is thirty five.",
577
+ examples: %w[35.0.thirty_five? 36.0.thirty_five? 0.5.thirty_five?]
578
+ },
579
+ "thirty_six?" => {
580
+ name: "thirty_six?",
581
+ description: "returns whether the decimal is thirty six.",
582
+ examples: %w[36.0.thirty_six? 37.0.thirty_six? 0.5.thirty_six?]
583
+ },
584
+ "thirty_seven?" => {
585
+ name: "thirty_seven?",
586
+ description: "returns whether the decimal is thirty seven.",
587
+ examples: %w[37.0.thirty_seven? 38.0.thirty_seven? 0.5.thirty_seven?]
588
+ },
589
+ "thirty_eight?" => {
590
+ name: "thirty_eight?",
591
+ description: "returns whether the decimal is thirty eight.",
592
+ examples: %w[38.0.thirty_eight? 39.0.thirty_eight? 0.5.thirty_eight?]
593
+ },
594
+ "thirty_nine?" => {
595
+ name: "thirty_nine?",
596
+ description: "returns whether the decimal is thirty nine.",
597
+ examples: %w[39.0.thirty_nine? 40.0.thirty_nine? 0.5.thirty_nine?]
598
+ },
599
+ "forty?" => {
600
+ name: "forty?",
601
+ description: "returns whether the decimal is forty.",
602
+ examples: %w[40.0.forty? 41.0.forty? 0.5.forty?]
603
+ },
604
+ "forty_one?" => {
605
+ name: "forty_one?",
606
+ description: "returns whether the decimal is forty one.",
607
+ examples: %w[41.0.forty_one? 42.0.forty_one? 0.5.forty_one?]
608
+ },
609
+ "forty_two?" => {
610
+ name: "forty_two?",
611
+ description: "returns whether the decimal is forty two.",
612
+ examples: %w[42.0.forty_two? 43.0.forty_two? 0.5.forty_two?]
613
+ },
614
+ "forty_three?" => {
615
+ name: "forty_three?",
616
+ description: "returns whether the decimal is forty three.",
617
+ examples: %w[43.0.forty_three? 44.0.forty_three? 0.5.forty_three?]
618
+ },
619
+ "forty_four?" => {
620
+ name: "forty_four?",
621
+ description: "returns whether the decimal is forty four.",
622
+ examples: %w[44.0.forty_four? 45.0.forty_four? 0.5.forty_four?]
623
+ },
624
+ "forty_five?" => {
625
+ name: "forty_five?",
626
+ description: "returns whether the decimal is forty five.",
627
+ examples: %w[45.0.forty_five? 46.0.forty_five? 0.5.forty_five?]
628
+ },
629
+ "forty_six?" => {
630
+ name: "forty_six?",
631
+ description: "returns whether the decimal is forty six.",
632
+ examples: %w[46.0.forty_six? 47.0.forty_six? 0.5.forty_six?]
633
+ },
634
+ "forty_seven?" => {
635
+ name: "forty_seven?",
636
+ description: "returns whether the decimal is forty seven.",
637
+ examples: %w[47.0.forty_seven? 48.0.forty_seven? 0.5.forty_seven?]
638
+ },
639
+ "forty_eight?" => {
640
+ name: "forty_eight?",
641
+ description: "returns whether the decimal is forty eight.",
642
+ examples: %w[48.0.forty_eight? 49.0.forty_eight? 0.5.forty_eight?]
643
+ },
644
+ "forty_nine?" => {
645
+ name: "forty_nine?",
646
+ description: "returns whether the decimal is forty nine.",
647
+ examples: %w[49.0.forty_nine? 50.0.forty_nine? 0.5.forty_nine?]
648
+ },
649
+ "fifty?" => {
650
+ name: "fifty?",
651
+ description: "returns whether the decimal is fifty.",
652
+ examples: %w[50.0.fifty? 51.0.fifty? 0.5.fifty?]
653
+ },
654
+ "fifty_one?" => {
655
+ name: "fifty_one?",
656
+ description: "returns whether the decimal is fifty one.",
657
+ examples: %w[51.0.fifty_one? 52.0.fifty_one? 0.5.fifty_one?]
658
+ },
659
+ "fifty_two?" => {
660
+ name: "fifty_two?",
661
+ description: "returns whether the decimal is fifty two.",
662
+ examples: %w[52.0.fifty_two? 53.0.fifty_two? 0.5.fifty_two?]
663
+ },
664
+ "fifty_three?" => {
665
+ name: "fifty_three?",
666
+ description: "returns whether the decimal is fifty three.",
667
+ examples: %w[53.0.fifty_three? 54.0.fifty_three? 0.5.fifty_three?]
668
+ },
669
+ "fifty_four?" => {
670
+ name: "fifty_four?",
671
+ description: "returns whether the decimal is fifty four.",
672
+ examples: %w[54.0.fifty_four? 55.0.fifty_four? 0.5.fifty_four?]
673
+ },
674
+ "fifty_five?" => {
675
+ name: "fifty_five?",
676
+ description: "returns whether the decimal is fifty five.",
677
+ examples: %w[55.0.fifty_five? 56.0.fifty_five? 0.5.fifty_five?]
678
+ },
679
+ "fifty_six?" => {
680
+ name: "fifty_six?",
681
+ description: "returns whether the decimal is fifty six.",
682
+ examples: %w[56.0.fifty_six? 57.0.fifty_six? 0.5.fifty_six?]
683
+ },
684
+ "fifty_seven?" => {
685
+ name: "fifty_seven?",
686
+ description: "returns whether the decimal is fifty seven.",
687
+ examples: %w[57.0.fifty_seven? 58.0.fifty_seven? 0.5.fifty_seven?]
688
+ },
689
+ "fifty_eight?" => {
690
+ name: "fifty_eight?",
691
+ description: "returns whether the decimal is fifty eight.",
692
+ examples: %w[58.0.fifty_eight? 59.0.fifty_eight? 0.5.fifty_eight?]
693
+ },
694
+ "fifty_nine?" => {
695
+ name: "fifty_nine?",
696
+ description: "returns whether the decimal is fifty nine.",
697
+ examples: %w[59.0.fifty_nine? 60.0.fifty_nine? 0.5.fifty_nine?]
698
+ },
699
+ "sixty?" => {
700
+ name: "sixty?",
701
+ description: "returns whether the decimal is sixty.",
702
+ examples: %w[60.0.sixty? 61.0.sixty? 0.5.sixty?]
703
+ },
704
+ "sixty_one?" => {
705
+ name: "sixty_one?",
706
+ description: "returns whether the decimal is sixty one.",
707
+ examples: %w[61.0.sixty_one? 62.0.sixty_one? 0.5.sixty_one?]
708
+ },
709
+ "sixty_two?" => {
710
+ name: "sixty_two?",
711
+ description: "returns whether the decimal is sixty two.",
712
+ examples: %w[62.0.sixty_two? 63.0.sixty_two? 0.5.sixty_two?]
713
+ },
714
+ "sixty_three?" => {
715
+ name: "sixty_three?",
716
+ description: "returns whether the decimal is sixty three.",
717
+ examples: %w[63.0.sixty_three? 64.0.sixty_three? 0.5.sixty_three?]
718
+ },
719
+ "sixty_four?" => {
720
+ name: "sixty_four?",
721
+ description: "returns whether the decimal is sixty four.",
722
+ examples: %w[64.0.sixty_four? 65.0.sixty_four? 0.5.sixty_four?]
723
+ },
724
+ "sixty_five?" => {
725
+ name: "sixty_five?",
726
+ description: "returns whether the decimal is sixty five.",
727
+ examples: %w[65.0.sixty_five? 66.0.sixty_five? 0.5.sixty_five?]
728
+ },
729
+ "sixty_six?" => {
730
+ name: "sixty_six?",
731
+ description: "returns whether the decimal is sixty six.",
732
+ examples: %w[66.0.sixty_six? 67.0.sixty_six? 0.5.sixty_six?]
733
+ },
734
+ "sixty_seven?" => {
735
+ name: "sixty_seven?",
736
+ description: "returns whether the decimal is sixty seven.",
737
+ examples: %w[67.0.sixty_seven? 68.0.sixty_seven? 0.5.sixty_seven?]
738
+ },
739
+ "sixty_eight?" => {
740
+ name: "sixty_eight?",
741
+ description: "returns whether the decimal is sixty eight.",
742
+ examples: %w[68.0.sixty_eight? 69.0.sixty_eight? 0.5.sixty_eight?]
743
+ },
744
+ "sixty_nine?" => {
745
+ name: "sixty_nine?",
746
+ description: "returns whether the decimal is sixty nine.",
747
+ examples: %w[69.0.sixty_nine? 70.0.sixty_nine? 0.5.sixty_nine?]
748
+ },
749
+ "seventy?" => {
750
+ name: "seventy?",
751
+ description: "returns whether the decimal is seventy.",
752
+ examples: %w[70.0.seventy? 71.0.seventy? 0.5.seventy?]
753
+ },
754
+ "seventy_one?" => {
755
+ name: "seventy_one?",
756
+ description: "returns whether the decimal is seventy one.",
757
+ examples: %w[71.0.seventy_one? 72.0.seventy_one? 0.5.seventy_one?]
758
+ },
759
+ "seventy_two?" => {
760
+ name: "seventy_two?",
761
+ description: "returns whether the decimal is seventy two.",
762
+ examples: %w[72.0.seventy_two? 73.0.seventy_two? 0.5.seventy_two?]
763
+ },
764
+ "seventy_three?" => {
765
+ name: "seventy_three?",
766
+ description: "returns whether the decimal is seventy three.",
767
+ examples: %w[
768
+ 73.0.seventy_three?
769
+ 74.0.seventy_three?
770
+ 0.5.seventy_three?
771
+ ]
772
+ },
773
+ "seventy_four?" => {
774
+ name: "seventy_four?",
775
+ description: "returns whether the decimal is seventy four.",
776
+ examples: %w[74.0.seventy_four? 75.0.seventy_four? 0.5.seventy_four?]
777
+ },
778
+ "seventy_five?" => {
779
+ name: "seventy_five?",
780
+ description: "returns whether the decimal is seventy five.",
781
+ examples: %w[75.0.seventy_five? 76.0.seventy_five? 0.5.seventy_five?]
782
+ },
783
+ "seventy_six?" => {
784
+ name: "seventy_six?",
785
+ description: "returns whether the decimal is seventy six.",
786
+ examples: %w[76.0.seventy_six? 77.0.seventy_six? 0.5.seventy_six?]
787
+ },
788
+ "seventy_seven?" => {
789
+ name: "seventy_seven?",
790
+ description: "returns whether the decimal is seventy seven.",
791
+ examples: %w[
792
+ 77.0.seventy_seven?
793
+ 78.0.seventy_seven?
794
+ 0.5.seventy_seven?
795
+ ]
796
+ },
797
+ "seventy_eight?" => {
798
+ name: "seventy_eight?",
799
+ description: "returns whether the decimal is seventy eight.",
800
+ examples: %w[
801
+ 78.0.seventy_eight?
802
+ 79.0.seventy_eight?
803
+ 0.5.seventy_eight?
804
+ ]
805
+ },
806
+ "seventy_nine?" => {
807
+ name: "seventy_nine?",
808
+ description: "returns whether the decimal is seventy nine.",
809
+ examples: %w[79.0.seventy_nine? 80.0.seventy_nine? 0.5.seventy_nine?]
810
+ },
811
+ "eighty?" => {
812
+ name: "eighty?",
813
+ description: "returns whether the decimal is eighty.",
814
+ examples: %w[80.0.eighty? 81.0.eighty? 0.5.eighty?]
815
+ },
816
+ "eighty_one?" => {
817
+ name: "eighty_one?",
818
+ description: "returns whether the decimal is eighty one.",
819
+ examples: %w[81.0.eighty_one? 82.0.eighty_one? 0.5.eighty_one?]
820
+ },
821
+ "eighty_two?" => {
822
+ name: "eighty_two?",
823
+ description: "returns whether the decimal is eighty two.",
824
+ examples: %w[82.0.eighty_two? 83.0.eighty_two? 0.5.eighty_two?]
825
+ },
826
+ "eighty_three?" => {
827
+ name: "eighty_three?",
828
+ description: "returns whether the decimal is eighty three.",
829
+ examples: %w[83.0.eighty_three? 84.0.eighty_three? 0.5.eighty_three?]
830
+ },
831
+ "eighty_four?" => {
832
+ name: "eighty_four?",
833
+ description: "returns whether the decimal is eighty four.",
834
+ examples: %w[84.0.eighty_four? 85.0.eighty_four? 0.5.eighty_four?]
835
+ },
836
+ "eighty_five?" => {
837
+ name: "eighty_five?",
838
+ description: "returns whether the decimal is eighty five.",
839
+ examples: %w[85.0.eighty_five? 86.0.eighty_five? 0.5.eighty_five?]
840
+ },
841
+ "eighty_six?" => {
842
+ name: "eighty_six?",
843
+ description: "returns whether the decimal is eighty six.",
844
+ examples: %w[86.0.eighty_six? 87.0.eighty_six? 0.5.eighty_six?]
845
+ },
846
+ "eighty_seven?" => {
847
+ name: "eighty_seven?",
848
+ description: "returns whether the decimal is eighty seven.",
849
+ examples: %w[87.0.eighty_seven? 88.0.eighty_seven? 0.5.eighty_seven?]
850
+ },
851
+ "eighty_eight?" => {
852
+ name: "eighty_eight?",
853
+ description: "returns whether the decimal is eighty eight.",
854
+ examples: %w[88.0.eighty_eight? 89.0.eighty_eight? 0.5.eighty_eight?]
855
+ },
856
+ "eighty_nine?" => {
857
+ name: "eighty_nine?",
858
+ description: "returns whether the decimal is eighty nine.",
859
+ examples: %w[89.0.eighty_nine? 90.0.eighty_nine? 0.5.eighty_nine?]
860
+ },
861
+ "ninety?" => {
862
+ name: "ninety?",
863
+ description: "returns whether the decimal is ninety.",
864
+ examples: %w[90.0.ninety? 91.0.ninety? 0.5.ninety?]
865
+ },
866
+ "ninety_one?" => {
867
+ name: "ninety_one?",
868
+ description: "returns whether the decimal is ninety one.",
869
+ examples: %w[91.0.ninety_one? 92.0.ninety_one? 0.5.ninety_one?]
870
+ },
871
+ "ninety_two?" => {
872
+ name: "ninety_two?",
873
+ description: "returns whether the decimal is ninety two.",
874
+ examples: %w[92.0.ninety_two? 93.0.ninety_two? 0.5.ninety_two?]
875
+ },
876
+ "ninety_three?" => {
877
+ name: "ninety_three?",
878
+ description: "returns whether the decimal is ninety three.",
879
+ examples: %w[93.0.ninety_three? 94.0.ninety_three? 0.5.ninety_three?]
880
+ },
881
+ "ninety_four?" => {
882
+ name: "ninety_four?",
883
+ description: "returns whether the decimal is ninety four.",
884
+ examples: %w[94.0.ninety_four? 95.0.ninety_four? 0.5.ninety_four?]
885
+ },
886
+ "ninety_five?" => {
887
+ name: "ninety_five?",
888
+ description: "returns whether the decimal is ninety five.",
889
+ examples: %w[95.0.ninety_five? 96.0.ninety_five? 0.5.ninety_five?]
890
+ },
891
+ "ninety_six?" => {
892
+ name: "ninety_six?",
893
+ description: "returns whether the decimal is ninety six.",
894
+ examples: %w[96.0.ninety_six? 97.0.ninety_six? 0.5.ninety_six?]
895
+ },
896
+ "ninety_seven?" => {
897
+ name: "ninety_seven?",
898
+ description: "returns whether the decimal is ninety seven.",
899
+ examples: %w[97.0.ninety_seven? 98.0.ninety_seven? 0.5.ninety_seven?]
900
+ },
901
+ "ninety_eight?" => {
902
+ name: "ninety_eight?",
903
+ description: "returns whether the decimal is ninety eight.",
904
+ examples: %w[98.0.ninety_eight? 99.0.ninety_eight? 0.5.ninety_eight?]
905
+ },
906
+ "ninety_nine?" => {
907
+ name: "ninety_nine?",
908
+ description: "returns whether the decimal is ninety nine.",
909
+ examples: %w[99.0.ninety_nine? 100.0.ninety_nine? 0.5.ninety_nine?]
910
+ },
911
+ "one_hundred?" => {
912
+ name: "one_hundred?",
913
+ description: "returns whether the decimal is one hundred.",
914
+ examples: %w[100.0.one_hundred? 101.0.one_hundred? 0.5.one_hundred?]
915
+ }
916
+ }.freeze
917
+
918
+ def self.function_documentation(scope)
919
+ return INSTANCE_FUNCTIONS if scope == :instance
920
+
921
+ {}
922
+ end
923
+
6
924
  def initialize(*args, **_kargs, &_block)
7
925
  self.raw =
8
926
  if args.first.class.in?(NUMBER_CLASSES)
@@ -45,6 +963,15 @@ class Code
45
963
  when "/", "division"
46
964
  sig(args) { Integer | Decimal }
47
965
  code_division(code_value)
966
+ when "divide"
967
+ sig(args) { Integer | Decimal }
968
+ code_divide(code_value)
969
+ when "divide_modulo"
970
+ sig(args) { Integer | Decimal }
971
+ code_divide_modulo(code_value)
972
+ when "decimal_divide"
973
+ sig(args) { Integer | Decimal }
974
+ code_decimal_divide(code_value)
48
975
  when "<<", "left_shift"
49
976
  sig(args) { Integer | Decimal }
50
977
  code_left_shift(code_value)
@@ -57,21 +984,72 @@ class Code
57
984
  when "abs"
58
985
  sig(args)
59
986
  code_abs
987
+ when "between?"
988
+ sig(args) { [Integer | Decimal, Integer | Decimal] }
989
+ code_between?(*code_arguments.raw)
60
990
  when "ceil"
61
991
  sig(args) { Integer.maybe }
62
992
  code_ceil(code_value)
993
+ when "clamp"
994
+ sig(args) { [Integer | Decimal, Integer | Decimal] }
995
+ code_clamp(*code_arguments.raw)
996
+ when "day", "days"
997
+ sig(args)
998
+ code_days
63
999
  when "floor"
64
1000
  sig(args) { Integer.maybe }
65
1001
  code_floor(code_value)
1002
+ when "hour", "hours"
1003
+ sig(args)
1004
+ code_hours
1005
+ when "minute", "minutes"
1006
+ sig(args)
1007
+ code_minutes
1008
+ when "month", "months"
1009
+ sig(args)
1010
+ code_months
1011
+ when "next", "successor"
1012
+ sig(args)
1013
+ code_next
1014
+ when "next_decimal"
1015
+ sig(args)
1016
+ code_next_decimal
1017
+ when "previous", "predecessor"
1018
+ sig(args)
1019
+ code_previous
1020
+ when "previous_decimal"
1021
+ sig(args)
1022
+ code_previous_decimal
1023
+ when "remainder"
1024
+ sig(args) { Integer | Decimal }
1025
+ code_remainder(code_value)
66
1026
  when "round"
67
1027
  sig(args) { Integer.maybe }
68
1028
  code_round(code_value)
1029
+ when "second", "seconds"
1030
+ sig(args)
1031
+ code_seconds
69
1032
  when "sqrt"
70
1033
  sig(args)
71
1034
  code_sqrt
72
1035
  when "truncate"
73
1036
  sig(args) { Integer.maybe }
74
1037
  code_truncate(code_value)
1038
+ when "to_fixed"
1039
+ sig(args) { Integer.maybe }
1040
+ code_to_fixed(code_value)
1041
+ when "to_precision"
1042
+ sig(args) { Integer.maybe }
1043
+ code_to_precision(code_value)
1044
+ when "to_exponential"
1045
+ sig(args) { Integer.maybe }
1046
+ code_to_exponential(code_value)
1047
+ when "week", "weeks"
1048
+ sig(args)
1049
+ code_weeks
1050
+ when "year", "years"
1051
+ sig(args)
1052
+ code_years
75
1053
  when "|", "bitwise_or"
76
1054
  sig(args) { Integer | Decimal }
77
1055
  code_bitwise_or(code_value)
@@ -87,6 +1065,30 @@ class Code
87
1065
  when "negative?"
88
1066
  sig(args)
89
1067
  code_negative?
1068
+ when "non_zero?"
1069
+ sig(args)
1070
+ code_non_zero?
1071
+ when "integer?"
1072
+ sig(args)
1073
+ code_integer?
1074
+ when "finite?"
1075
+ sig(args)
1076
+ code_finite?
1077
+ when "infinite?"
1078
+ sig(args)
1079
+ code_infinite?
1080
+ when "not_a_number?"
1081
+ sig(args)
1082
+ code_not_a_number?
1083
+ when "numerator"
1084
+ sig(args)
1085
+ code_numerator
1086
+ when "denominator"
1087
+ sig(args)
1088
+ code_denominator
1089
+ when "magnitude"
1090
+ sig(args)
1091
+ code_magnitude
90
1092
  when "zero?"
91
1093
  sig(args)
92
1094
  code_zero?
@@ -430,6 +1432,10 @@ class Code
430
1432
  Decimal.new(raw / code_other.raw)
431
1433
  end
432
1434
 
1435
+ def code_decimal_divide(other)
1436
+ code_division(other)
1437
+ end
1438
+
433
1439
  def code_floor(n = nil)
434
1440
  code_n = n.to_code
435
1441
  code_n = Integer.new(0) if code_n.nothing?
@@ -437,6 +1443,34 @@ class Code
437
1443
  Decimal.new(raw.floor(code_n.raw))
438
1444
  end
439
1445
 
1446
+ def code_days
1447
+ Duration.new(raw.days)
1448
+ end
1449
+
1450
+ def code_hours
1451
+ Duration.new(raw.hours)
1452
+ end
1453
+
1454
+ def code_minutes
1455
+ Duration.new(raw.minutes)
1456
+ end
1457
+
1458
+ def code_months
1459
+ Duration.new(::ActiveSupport::Duration.months(raw))
1460
+ end
1461
+
1462
+ def code_seconds
1463
+ Duration.new(raw.seconds)
1464
+ end
1465
+
1466
+ def code_weeks
1467
+ Duration.new(raw.weeks)
1468
+ end
1469
+
1470
+ def code_years
1471
+ Duration.new(::ActiveSupport::Duration.years(raw))
1472
+ end
1473
+
440
1474
  def code_left_shift(other)
441
1475
  code_other = other.to_code
442
1476
 
@@ -498,6 +1532,30 @@ class Code
498
1532
  String.new(raw.to_s("F"))
499
1533
  end
500
1534
 
1535
+ def code_to_fixed(digits = nil)
1536
+ code_digits = digits.to_code
1537
+ code_digits = Integer.new(0) if code_digits.nothing?
1538
+
1539
+ String.new(format("%.#{code_digits.raw}f", raw))
1540
+ end
1541
+
1542
+ def code_to_precision(precision = nil)
1543
+ code_precision = precision.to_code
1544
+ code_precision =
1545
+ Integer.new(
1546
+ raw.to_s("F").delete(".-").length
1547
+ ) if code_precision.nothing?
1548
+
1549
+ String.new(format("%.#{code_precision.raw}g", raw))
1550
+ end
1551
+
1552
+ def code_to_exponential(digits = nil)
1553
+ code_digits = digits.to_code
1554
+ code_digits = Integer.new(6) if code_digits.nothing?
1555
+
1556
+ String.new(format("%.#{code_digits.raw}e", raw))
1557
+ end
1558
+
501
1559
  def code_truncate(n = nil)
502
1560
  code_n = n.to_code
503
1561
  code_n = Integer.new(0) if code_n.nothing?
@@ -517,6 +1575,14 @@ class Code
517
1575
  Boolean.new(raw.positive?)
518
1576
  end
519
1577
 
1578
+ def code_next_decimal
1579
+ code_next
1580
+ end
1581
+
1582
+ def code_previous_decimal
1583
+ code_previous
1584
+ end
1585
+
520
1586
  def code_positive?
521
1587
  Boolean.new(raw.positive?)
522
1588
  end
@@ -525,6 +1591,38 @@ class Code
525
1591
  Boolean.new(raw.negative?)
526
1592
  end
527
1593
 
1594
+ def code_non_zero?
1595
+ Boolean.new(!raw.zero?)
1596
+ end
1597
+
1598
+ def code_integer?
1599
+ Boolean.new(raw.frac.zero?)
1600
+ end
1601
+
1602
+ def code_finite?
1603
+ Boolean.new(raw.finite?)
1604
+ end
1605
+
1606
+ def code_infinite?
1607
+ Boolean.new(!!raw.infinite?)
1608
+ end
1609
+
1610
+ def code_not_a_number?
1611
+ Boolean.new(raw.nan?)
1612
+ end
1613
+
1614
+ def code_numerator
1615
+ Integer.new(raw.to_r.numerator)
1616
+ end
1617
+
1618
+ def code_denominator
1619
+ Integer.new(raw.to_r.denominator)
1620
+ end
1621
+
1622
+ def code_magnitude
1623
+ code_abs
1624
+ end
1625
+
528
1626
  def code_zero?
529
1627
  Boolean.new(raw.zero?)
530
1628
  end