minting 1.7.0 → 1.7.3

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -112
  3. data/Rakefile +13 -1
  4. data/bin/bench_check +46 -0
  5. data/doc/Mint/Currency.html +446 -46
  6. data/doc/Mint/CurrencyRegistry.html +7 -7
  7. data/doc/Mint/Money.html +203 -177
  8. data/doc/Mint/RangeStepPatch.html +277 -0
  9. data/doc/Mint/Registry.html +842 -0
  10. data/doc/Mint/UnknownCurrency.html +2 -2
  11. data/doc/Mint.html +385 -66
  12. data/doc/Minting.html +3 -3
  13. data/doc/_index.html +24 -9
  14. data/doc/agents/api_review-2026-06-15.md +342 -0
  15. data/doc/class_list.html +1 -1
  16. data/doc/file.README.html +97 -89
  17. data/doc/index.html +97 -89
  18. data/doc/method_list.html +97 -25
  19. data/doc/top-level-namespace.html +13 -5
  20. data/lib/minting/currency/currency.rb +75 -0
  21. data/lib/minting/mint/aliases.rb +3 -0
  22. data/lib/minting/mint/dsl/{refinements.rb → numeric.rb} +6 -5
  23. data/lib/minting/mint/dsl/range.rb +31 -18
  24. data/lib/minting/mint/dsl/string.rb +12 -0
  25. data/lib/minting/mint/dsl/top_level.rb +3 -0
  26. data/lib/minting/mint/locale_backend.rb +29 -0
  27. data/lib/minting/mint/mint.rb +28 -12
  28. data/lib/minting/mint/parser/parser.rb +62 -0
  29. data/lib/minting/mint/parser/separators.rb +39 -0
  30. data/lib/minting/mint/registry/registration.rb +33 -0
  31. data/lib/minting/mint/registry/registry.rb +38 -0
  32. data/lib/minting/mint/registry/symbols.rb +49 -0
  33. data/lib/minting/mint/registry/zeros.rb +18 -0
  34. data/lib/minting/mint.rb +13 -16
  35. data/lib/minting/money/allocation/allocation.rb +25 -0
  36. data/lib/minting/money/{allocation.rb → allocation/split.rb} +1 -19
  37. data/lib/minting/money/arithmetics/methods.rb +27 -0
  38. data/lib/minting/money/{arithmetics.rb → arithmetics/operators.rb} +0 -21
  39. data/lib/minting/money/clamp.rb +66 -0
  40. data/lib/minting/money/coercion.rb +10 -0
  41. data/lib/minting/money/comparable.rb +6 -0
  42. data/lib/minting/money/constructors.rb +14 -9
  43. data/lib/minting/money/format/formatting.rb +60 -0
  44. data/lib/minting/money/{formatting.rb → format/to_s.rb} +13 -36
  45. data/lib/minting/money/money.rb +12 -58
  46. data/lib/minting/version.rb +1 -1
  47. metadata +29 -19
  48. data/lib/minting/mint/currency/currency.rb +0 -36
  49. data/lib/minting/mint/currency/currency_registry.rb +0 -67
  50. data/lib/minting/mint/currency/world_currencies.rb +0 -16
  51. data/lib/minting/mint/parser.rb +0 -85
  52. /data/doc/agents/{AGENTS.md → expired/AGENTS.md} +0 -0
  53. /data/doc/agents/{copilot-instructions.md → expired/copilot-instructions.md} +0 -0
  54. /data/doc/agents/{gemini_gem_evaluation.md → expired/gemini_gem_evaluation.md} +0 -0
  55. /data/doc/agents/{recommendations.md → expired/recommendations.md} +0 -0
  56. /data/doc/agents/{rubocop-issues.md → expired/rubocop-issues.md} +0 -0
data/doc/Mint.html CHANGED
@@ -90,8 +90,8 @@
90
90
 
91
91
  <dl>
92
92
  <dt>Defined in:</dt>
93
- <dd>lib/minting/mint/dsl.rb<span class="defines">,<br>
94
- lib/minting/mint/mint.rb,<br> lib/minting/mint/parser.rb,<br> lib/minting/money/money.rb,<br> lib/minting/money/coercion.rb,<br> lib/minting/money/allocation.rb,<br> lib/minting/money/comparable.rb,<br> lib/minting/money/conversion.rb,<br> lib/minting/money/formatting.rb,<br> lib/minting/money/arithmetics.rb,<br> lib/minting/money/constructors.rb,<br> lib/minting/mint/currency/currency.rb,<br> lib/minting/mint/currency/world_currencies.rb,<br> lib/minting/mint/currency/currency_registry.rb</span>
93
+ <dd>lib/minting/mint/mint.rb<span class="defines">,<br>
94
+ lib/minting/money/clamp.rb,<br> lib/minting/money/money.rb,<br> lib/minting/mint/dsl/range.rb,<br> lib/minting/money/coercion.rb,<br> lib/minting/mint/dsl/string.rb,<br> lib/minting/mint/dsl/numeric.rb,<br> lib/minting/money/comparable.rb,<br> lib/minting/money/conversion.rb,<br> lib/minting/currency/currency.rb,<br> lib/minting/money/format/to_s.rb,<br> lib/minting/mint/dsl/top_level.rb,<br> lib/minting/mint/parser/parser.rb,<br> lib/minting/money/constructors.rb,<br> lib/minting/mint/locale_backend.rb,<br> lib/minting/mint/registry/zeros.rb,<br> lib/minting/mint/registry/symbols.rb,<br> lib/minting/mint/parser/separators.rb,<br> lib/minting/mint/registry/registry.rb,<br> lib/minting/money/allocation/split.rb,<br> lib/minting/money/format/formatting.rb,<br> lib/minting/money/arithmetics/methods.rb,<br> lib/minting/mint/registry/registration.rb,<br> lib/minting/money/allocation/allocation.rb,<br> lib/minting/money/arithmetics/operators.rb</span>
95
95
 
96
96
  </dd>
97
97
  </dl>
@@ -100,7 +100,7 @@
100
100
 
101
101
  <h2>Overview</h2><div class="docstring">
102
102
  <div class="discussion">
103
- <p>Mint currency store (internal)</p>
103
+ <p>Mint registry: manages all cached state</p>
104
104
 
105
105
  </div>
106
106
  </div>
@@ -111,7 +111,7 @@
111
111
  <p class="children">
112
112
 
113
113
 
114
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mint/CurrencyRegistry.html" title="Mint::CurrencyRegistry (module)">CurrencyRegistry</a></span>
114
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mint/RangeStepPatch.html" title="Mint::RangeStepPatch (module)">RangeStepPatch</a></span>, <span class='object_link'><a href="Mint/Registry.html" title="Mint::Registry (module)">Registry</a></span>
115
115
 
116
116
 
117
117
 
@@ -123,6 +123,36 @@
123
123
 
124
124
 
125
125
 
126
+ <h2>Class Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
127
+ <ul class="summary">
128
+
129
+ <li class="public ">
130
+ <span class="summary_signature">
131
+
132
+ <a href="#locale_backend-class_method" title="locale_backend (class method)">.<strong>locale_backend</strong> &#x21d2; Proc, ... </a>
133
+
134
+
135
+
136
+ </span>
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ <span class="summary_desc"><div class='inline'><p>Optional callable that returns a Hash with locale-aware formatting defaults.</p></div></span>
150
+
151
+ </li>
152
+
153
+
154
+ </ul>
155
+
126
156
 
127
157
 
128
158
 
@@ -137,7 +167,7 @@
137
167
  <li class="public ">
138
168
  <span class="summary_signature">
139
169
 
140
- <a href="#currency-class_method" title="currency (class method)">.<strong>currency</strong>(currency) &#x21d2; Currency<sup>?</sup> </a>
170
+ <a href="#currency_for_code-class_method" title="currency_for_code (class method)">.<strong>currency_for_code</strong>(code) &#x21d2; Currency<sup>?</sup> </a>
141
171
 
142
172
 
143
173
 
@@ -151,7 +181,29 @@
151
181
 
152
182
 
153
183
 
154
- <span class="summary_desc"><div class='inline'><p>Finds a registered currency by its code, symbol, or retrieves it directly if already a Currency object.</p></div></span>
184
+ <span class="summary_desc"><div class='inline'><p>Looks up a registered currency by its alpha code.</p></div></span>
185
+
186
+ </li>
187
+
188
+
189
+ <li class="public ">
190
+ <span class="summary_signature">
191
+
192
+ <a href="#currency_for_symbol-class_method" title="currency_for_symbol (class method)">.<strong>currency_for_symbol</strong>(symbol) &#x21d2; Currency<sup>?</sup> </a>
193
+
194
+
195
+
196
+ </span>
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+ <span class="summary_desc"><div class='inline'><p>Looks up a currency by its display symbol.</p></div></span>
155
207
 
156
208
  </li>
157
209
 
@@ -217,7 +269,7 @@
217
269
 
218
270
 
219
271
 
220
- <span class="summary_desc"><div class='inline'></div></span>
272
+ <span class="summary_desc"><div class='inline'><p>Registers top-level ::Money and ::Currency constants as aliases for Mint's classes.</p></div></span>
221
273
 
222
274
  </li>
223
275
 
@@ -239,7 +291,29 @@
239
291
  <span class="private note title">private</span>
240
292
 
241
293
 
242
- <span class="summary_desc"><div class='inline'><p>Loads ISO world currencies from YAML file into the registry.</p></div></span>
294
+ <span class="summary_desc"><div class='inline'><p>The frozen world-currencies hash.</p></div></span>
295
+
296
+ </li>
297
+
298
+
299
+ <li class="public ">
300
+ <span class="summary_signature">
301
+
302
+ <a href="#zero-class_method" title="zero (class method)">.<strong>zero</strong>(currency) &#x21d2; Money </a>
303
+
304
+
305
+
306
+ </span>
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+ <span class="summary_desc"><div class='inline'><p>Returns a zero <span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span> in the given currency, useful as a default value for discounts, totals, or placeholders.</p></div></span>
243
317
 
244
318
  </li>
245
319
 
@@ -281,15 +355,98 @@
281
355
 
282
356
 
283
357
 
358
+ <div id="class_attr_details" class="attr_details">
359
+ <h2>Class Attribute Details</h2>
360
+
361
+
362
+ <span id="locale_backend=-class_method"></span>
363
+ <div class="method_details first">
364
+ <h3 class="signature first" id="locale_backend-class_method">
365
+
366
+ .<strong>locale_backend</strong> &#x21d2; <tt>Proc</tt>, ...
367
+
368
+
369
+
370
+
371
+
372
+ </h3><div class="docstring">
373
+ <div class="discussion">
374
+ <p>Optional callable that returns a Hash with locale-aware formatting defaults.</p>
375
+ <p>The callable receives no arguments and returns a Hash with these keys:</p>
376
+ <pre class="code ruby"><code class="ruby">[+:decimal+] Decimal separator (e.g. +&quot;,&quot;+)
377
+ [+:thousand+] Thousands delimiter (e.g. +&quot;.&quot;+)
378
+ [+:format+] Format template string (e.g. +&quot;%&lt;amount&gt;f %&lt;symbol&gt;s&quot;+)
379
+ </code></pre>
380
+ <p>When set, <code>#to_s</code> and <code>#format</code> use these values as fallbacks when the
381
+ corresponding parameter is not explicitly provided.</p>
382
+
383
+ </div>
384
+ </div>
385
+ <div class="tags">
386
+
387
+ <div class="examples">
388
+ <h4 class="tag_title">Examples:</h4>
389
+
390
+
391
+ <h5 class="example_title"><div class='inline'><p>Rails I18n integration (in minting-rails railtie)</p></div></h5>
392
+
393
+ <pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_locale_backend'>locale_backend</span> <span class='op'>=</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span>
394
+ <span class='id identifier rubyid_fmt'>fmt</span> <span class='op'>=</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>number.currency.format</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
395
+ <span class='lbrace'>{</span>
396
+ <span class='label'>decimal:</span> <span class='id identifier rubyid_fmt'>fmt</span><span class='lbracket'>[</span><span class='symbol'>:separator</span><span class='rbracket'>]</span><span class='comma'>,</span>
397
+ <span class='label'>thousand:</span> <span class='id identifier rubyid_fmt'>fmt</span><span class='lbracket'>[</span><span class='symbol'>:delimiter</span><span class='rbracket'>]</span><span class='comma'>,</span>
398
+ <span class='label'>format:</span> <span class='id identifier rubyid_fmt'>fmt</span><span class='lbracket'>[</span><span class='symbol'>:format</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%n %u</span><span class='tstring_end'>&#39;</span></span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;amount&gt;f %&lt;symbol&gt;s</span><span class='tstring_end'>&#39;</span></span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;symbol&gt;s%&lt;amount&gt;f</span><span class='tstring_end'>&#39;</span></span>
399
+ <span class='rbrace'>}</span>
400
+ <span class='rbrace'>}</span></code></pre>
401
+
402
+ </div>
403
+
404
+ <p class="tag_title">Returns:</p>
405
+ <ul class="return">
406
+
407
+ <li>
408
+
409
+
410
+ <span class='type'>(<tt>Proc</tt>, <tt>#call</tt>, <tt>nil</tt>)</span>
411
+
412
+
413
+
414
+ </li>
415
+
416
+ </ul>
417
+
418
+ </div><table class="source_code">
419
+ <tr>
420
+ <td>
421
+ <pre class="lines">
422
+
423
+
424
+ 27
425
+ 28
426
+ 29</pre>
427
+ </td>
428
+ <td>
429
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/locale_backend.rb', line 27</span>
430
+
431
+ <span class='kw'>def</span> <span class='id identifier rubyid_locale_backend'>locale_backend</span>
432
+ <span class='ivar'>@locale_backend</span>
433
+ <span class='kw'>end</span></pre>
434
+ </td>
435
+ </tr>
436
+ </table>
437
+ </div>
438
+
439
+ </div>
440
+
284
441
 
285
442
  <div id="class_method_details" class="method_details_list">
286
443
  <h2>Class Method Details</h2>
287
444
 
288
445
 
289
446
  <div class="method_details first">
290
- <h3 class="signature first" id="currency-class_method">
447
+ <h3 class="signature first" id="currency_for_code-class_method">
291
448
 
292
- .<strong>currency</strong>(currency) &#x21d2; <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
449
+ .<strong>currency_for_code</strong>(code) &#x21d2; <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
293
450
 
294
451
 
295
452
 
@@ -297,8 +454,8 @@
297
454
 
298
455
  </h3><div class="docstring">
299
456
  <div class="discussion">
300
- <p>Finds a registered currency by its code, symbol,
301
- or retrieves it directly if already a Currency object.</p>
457
+ <p>Looks up a registered currency by its alpha code.</p>
458
+ <p>Unlike currency, this performs a direct hash lookup and only accepts strings.</p>
302
459
 
303
460
  </div>
304
461
  </div>
@@ -308,15 +465,15 @@ or retrieves it directly if already a Currency object.</p>
308
465
 
309
466
  <li>
310
467
 
311
- <span class='name'>currency</span>
468
+ <span class='name'>code</span>
312
469
 
313
470
 
314
- <span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
471
+ <span class='type'>(<tt>String</tt>)</span>
315
472
 
316
473
 
317
474
 
318
475
  &mdash;
319
- <div class='inline'><p>the currency identifier or object</p></div>
476
+ <div class='inline'><p>the currency code</p></div>
320
477
 
321
478
  </li>
322
479
 
@@ -333,7 +490,7 @@ or retrieves it directly if already a Currency object.</p>
333
490
 
334
491
 
335
492
  &mdash;
336
- <div class='inline'><p>the registered Currency instance or nil if not found</p></div>
493
+ <div class='inline'><p>the registered Currency, or <code>nil</code> if not found</p></div>
337
494
 
338
495
  </li>
339
496
 
@@ -345,25 +502,88 @@ or retrieves it directly if already a Currency object.</p>
345
502
  <pre class="lines">
346
503
 
347
504
 
348
- 22
349
- 23
350
- 24
351
- 25
352
- 26
353
505
  27
354
506
  28
355
507
  29</pre>
356
508
  </td>
357
509
  <td>
358
- <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 22</span>
359
-
360
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_currency'>currency</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
361
- <span class='kw'>case</span> <span class='id identifier rubyid_currency'>currency</span>
362
- <span class='kw'>when</span> <span class='kw'>nil</span> <span class='kw'>then</span> <span class='kw'>nil</span>
363
- <span class='kw'>when</span> <span class='const'><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></span> <span class='kw'>then</span> <span class='id identifier rubyid_currency'>currency</span>
364
- <span class='kw'>when</span> <span class='const'>String</span> <span class='kw'>then</span> <span class='const'><span class='object_link'><a href="Mint/CurrencyRegistry.html" title="Mint::CurrencyRegistry (module)">CurrencyRegistry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_currencies'><span class='object_link'><a href="Mint/CurrencyRegistry.html#currencies-instance_method" title="Mint::CurrencyRegistry#currencies (method)">currencies</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='rbracket'>]</span>
365
- <span class='kw'>else</span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>currency must be [Currency] ot [String] (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>&quot;</span></span>
366
- <span class='kw'>end</span>
510
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 27</span>
511
+
512
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_currency_for_code'>currency_for_code</span><span class='lparen'>(</span><span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span>
513
+ <span class='const'><span class='object_link'><a href="Mint/Registry.html" title="Mint::Registry (module)">Registry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_currencies'><span class='object_link'><a href="Mint/Registry.html#currencies-class_method" title="Mint::Registry.currencies (method)">currencies</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_code'>code</span><span class='rbracket'>]</span>
514
+ <span class='kw'>end</span></pre>
515
+ </td>
516
+ </tr>
517
+ </table>
518
+ </div>
519
+
520
+ <div class="method_details ">
521
+ <h3 class="signature " id="currency_for_symbol-class_method">
522
+
523
+ .<strong>currency_for_symbol</strong>(symbol) &#x21d2; <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
524
+
525
+
526
+
527
+
528
+
529
+ </h3><div class="docstring">
530
+ <div class="discussion">
531
+ <p>Looks up a currency by its display symbol.</p>
532
+
533
+ </div>
534
+ </div>
535
+ <div class="tags">
536
+ <p class="tag_title">Parameters:</p>
537
+ <ul class="param">
538
+
539
+ <li>
540
+
541
+ <span class='name'>symbol</span>
542
+
543
+
544
+ <span class='type'>(<tt>String</tt>)</span>
545
+
546
+
547
+
548
+ &mdash;
549
+ <div class='inline'><p>the display symbol (e.g. &quot;$&quot;, &quot;R$&quot;)</p></div>
550
+
551
+ </li>
552
+
553
+ </ul>
554
+
555
+ <p class="tag_title">Returns:</p>
556
+ <ul class="return">
557
+
558
+ <li>
559
+
560
+
561
+ <span class='type'>(<tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
562
+
563
+
564
+
565
+ &mdash;
566
+ <div class='inline'><p>the highest-priority currency for the symbol</p></div>
567
+
568
+ </li>
569
+
570
+ </ul>
571
+
572
+ </div><table class="source_code">
573
+ <tr>
574
+ <td>
575
+ <pre class="lines">
576
+
577
+
578
+ 35
579
+ 36
580
+ 37</pre>
581
+ </td>
582
+ <td>
583
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 35</span>
584
+
585
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_currency_for_symbol'>currency_for_symbol</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span>
586
+ <span class='const'><span class='object_link'><a href="Mint/Registry.html" title="Mint::Registry (module)">Registry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_currency_for_symbol'><span class='object_link'><a href="Mint/Registry.html#currency_for_symbol-instance_method" title="Mint::Registry#currency_for_symbol (method)">currency_for_symbol</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span>
367
587
  <span class='kw'>end</span></pre>
368
588
  </td>
369
589
  </tr>
@@ -603,15 +823,15 @@ or retrieves it directly if already a Currency object.</p>
603
823
  <pre class="lines">
604
824
 
605
825
 
606
- 40
607
- 41
608
- 42</pre>
826
+ 56
827
+ 57
828
+ 58</pre>
609
829
  </td>
610
830
  <td>
611
- <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 40</span>
831
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 56</span>
612
832
 
613
833
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_register_currency'>register_currency</span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>subunit:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>symbol:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='rparen'>)</span>
614
- <span class='const'><span class='object_link'><a href="Mint/CurrencyRegistry.html" title="Mint::CurrencyRegistry (module)">CurrencyRegistry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_register'><span class='object_link'><a href="Mint/CurrencyRegistry.html#register-instance_method" title="Mint::CurrencyRegistry#register (method)">register</a></span></span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>subunit:</span><span class='comma'>,</span> <span class='label'>symbol:</span><span class='comma'>,</span> <span class='label'>priority:</span><span class='rparen'>)</span>
834
+ <span class='const'><span class='object_link'><a href="Mint/Registry.html" title="Mint::Registry (module)">Registry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_register'><span class='object_link'><a href="Mint/Registry.html#register-class_method" title="Mint::Registry.register (method)">register</a></span></span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>subunit:</span><span class='comma'>,</span> <span class='label'>symbol:</span><span class='comma'>,</span> <span class='label'>priority:</span><span class='rparen'>)</span>
615
835
  <span class='kw'>end</span></pre>
616
836
  </td>
617
837
  </tr>
@@ -627,24 +847,49 @@ or retrieves it directly if already a Currency object.</p>
627
847
 
628
848
 
629
849
 
630
- </h3><table class="source_code">
850
+ </h3><div class="docstring">
851
+ <div class="discussion">
852
+ <p>Registers top-level ::Money and ::Currency constants as aliases for Mint's classes.</p>
853
+
854
+ </div>
855
+ </div>
856
+ <div class="tags">
857
+
858
+ <p class="tag_title">Raises:</p>
859
+ <ul class="raise">
860
+
861
+ <li>
862
+
863
+
864
+ <span class='type'>(<tt>NameError</tt>)</span>
865
+
866
+
867
+
868
+ &mdash;
869
+ <div class='inline'><p>if ::Money or ::Currency are already defined and differ</p></div>
870
+
871
+ </li>
872
+
873
+ </ul>
874
+
875
+ </div><table class="source_code">
631
876
  <tr>
632
877
  <td>
633
878
  <pre class="lines">
634
879
 
635
880
 
636
- 23
637
- 24
638
- 25
639
- 26
640
- 27
641
- 28
642
- 29
643
- 30
644
- 31</pre>
881
+ 8
882
+ 9
883
+ 10
884
+ 11
885
+ 12
886
+ 13
887
+ 14
888
+ 15
889
+ 16</pre>
645
890
  </td>
646
891
  <td>
647
- <pre class="code"><span class="info file"># File 'lib/minting/mint/dsl.rb', line 23</span>
892
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/dsl/top_level.rb', line 8</span>
648
893
 
649
894
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_use_top_level_constants!'>use_top_level_constants!</span>
650
895
  <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>defined?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="top-level-namespace.html#Money-constant" title="Money (constant)">Money</a></span></span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='kw'>defined?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="top-level-namespace.html#Currency-constant" title="Currency (constant)">Currency</a></span></span><span class='rparen'>)</span>
@@ -675,7 +920,7 @@ or retrieves it directly if already a Currency object.</p>
675
920
  <strong>This method is part of a private API.</strong>
676
921
  You should avoid using this method if possible, as it may be removed or be changed in the future.
677
922
  </p>
678
- <p>Loads ISO world currencies from YAML file into the registry.</p>
923
+ <p>Returns the frozen world-currencies hash.</p>
679
924
 
680
925
  </div>
681
926
  </div>
@@ -692,7 +937,7 @@ or retrieves it directly if already a Currency object.</p>
692
937
 
693
938
 
694
939
  &mdash;
695
- <div class='inline'><p>ISO-4217 world currencies mapped by code</p></div>
940
+ <div class='inline'><p>the frozen world-currencies hash</p></div>
696
941
 
697
942
  </li>
698
943
 
@@ -704,24 +949,98 @@ or retrieves it directly if already a Currency object.</p>
704
949
  <pre class="lines">
705
950
 
706
951
 
707
- 9
708
- 10
709
- 11
710
- 12
711
- 13
712
- 14
713
- 15</pre>
952
+ 19</pre>
714
953
  </td>
715
954
  <td>
716
- <pre class="code"><span class="info file"># File 'lib/minting/mint/currency/world_currencies.rb', line 9</span>
955
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 19</span>
956
+
957
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_world_currencies'>world_currencies</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Mint/Registry.html" title="Mint::Registry (module)">Registry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_world_currencies'><span class='object_link'><a href="Mint/Registry.html#world_currencies-class_method" title="Mint::Registry.world_currencies (method)">world_currencies</a></span></span></pre>
958
+ </td>
959
+ </tr>
960
+ </table>
961
+ </div>
962
+
963
+ <div class="method_details ">
964
+ <h3 class="signature " id="zero-class_method">
965
+
966
+ .<strong>zero</strong>(currency) &#x21d2; <tt><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></tt>
967
+
717
968
 
718
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_world_currencies'>world_currencies</span>
719
- <span class='ivar'>@world_currencies</span> <span class='op'>||=</span> <span class='kw'>begin</span>
720
- <span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>../../data</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid___dir__'>__dir__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>world-currencies.yaml</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
969
+
721
970
 
722
- <span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_load_file'>load_file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_entry'>entry</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>code</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Mint/Currency.html#initialize-instance_method" title="Mint::Currency#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_transform_keys'>transform_keys</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
723
- <span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
724
- <span class='kw'>end</span></pre>
971
+
972
+ </h3><div class="docstring">
973
+ <div class="discussion">
974
+ <p>Returns a zero <span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span> in the given currency, useful as a default value
975
+ for discounts, totals, or placeholders.</p>
976
+
977
+ </div>
978
+ </div>
979
+ <div class="tags">
980
+ <p class="tag_title">Parameters:</p>
981
+ <ul class="param">
982
+
983
+ <li>
984
+
985
+ <span class='name'>currency</span>
986
+
987
+
988
+ <span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
989
+
990
+
991
+
992
+ &mdash;
993
+ <div class='inline'><p>a currency code or object</p></div>
994
+
995
+ </li>
996
+
997
+ </ul>
998
+
999
+ <p class="tag_title">Returns:</p>
1000
+ <ul class="return">
1001
+
1002
+ <li>
1003
+
1004
+
1005
+ <span class='type'>(<tt><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></tt>)</span>
1006
+
1007
+
1008
+
1009
+ &mdash;
1010
+ <div class='inline'><p>a frozen zero-Money</p></div>
1011
+
1012
+ </li>
1013
+
1014
+ </ul>
1015
+ <p class="tag_title">Raises:</p>
1016
+ <ul class="raise">
1017
+
1018
+ <li>
1019
+
1020
+
1021
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
1022
+
1023
+
1024
+
1025
+ &mdash;
1026
+ <div class='inline'><p>if the currency can't be resolved</p></div>
1027
+
1028
+ </li>
1029
+
1030
+ </ul>
1031
+
1032
+ </div><table class="source_code">
1033
+ <tr>
1034
+ <td>
1035
+ <pre class="lines">
1036
+
1037
+
1038
+ 45</pre>
1039
+ </td>
1040
+ <td>
1041
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 45</span>
1042
+
1043
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_zero'>zero</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Mint/Registry.html" title="Mint::Registry (module)">Registry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_zero_for'><span class='object_link'><a href="Mint/Registry.html#zero_for-class_method" title="Mint::Registry.zero_for (method)">zero_for</a></span></span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve!'><span class='object_link'><a href="Mint/Currency.html#resolve!-class_method" title="Mint::Currency.resolve! (method)">resolve!</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span><span class='rparen'>)</span></pre>
725
1044
  </td>
726
1045
  </tr>
727
1046
  </table>
@@ -852,7 +1171,7 @@ or retrieves it directly if already a Currency object.</p>
852
1171
  33</pre>
853
1172
  </td>
854
1173
  <td>
855
- <pre class="code"><span class="info file"># File 'lib/minting/mint/parser.rb', line 22</span>
1174
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/parser/parser.rb', line 22</span>
856
1175
 
857
1176
  <span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
858
1177
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>input must be a String</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
@@ -860,7 +1179,7 @@ or retrieves it directly if already a Currency object.</p>
860
1179
  <span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
861
1180
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>input cannot be empty</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
862
1181
 
863
- <span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_currency'><span class='object_link'><a href="#currency-class_method" title="Mint.currency (method)">currency</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_parse_currency'>parse_currency</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
1182
+ <span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve'><span class='object_link'><a href="Mint/Currency.html#resolve-class_method" title="Mint::Currency.resolve (method)">resolve</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_parse_currency'>parse_currency</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
864
1183
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Currency [</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='embexpr_end'>}</span><span class='tstring_content'>] not registered</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_currency'>currency</span>
865
1184
 
866
1185
  <span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_normalize_amount'>normalize_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_parse_amount'>parse_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span><span class='rparen'>)</span>
@@ -876,9 +1195,9 @@ or retrieves it directly if already a Currency object.</p>
876
1195
  </div>
877
1196
 
878
1197
  <div id="footer">
879
- Generated on Wed Jun 10 01:35:30 2026 by
1198
+ Generated on Mon Jun 15 19:57:57 2026 by
880
1199
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
881
- 0.9.44 (ruby-4.0.1).
1200
+ 0.9.44 (ruby-4.0.5).
882
1201
  </div>
883
1202
 
884
1203
  </div>