minting 1.8.2 โ†’ 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -267,7 +267,7 @@ Overrides Range#step to handle Mint::Money step sizes on Ruby &lt; 4.0.</p>
267
267
  </div>
268
268
 
269
269
  <div id="footer">
270
- Generated on Tue Jun 16 20:22:19 2026 by
270
+ Generated on Mon Jun 22 16:47:02 2026 by
271
271
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
272
272
  0.9.44 (ruby-4.0.5).
273
273
  </div>
@@ -661,7 +661,9 @@
661
661
  15
662
662
  16
663
663
  17
664
- 18</pre>
664
+ 18
665
+ 19
666
+ 20</pre>
665
667
  </td>
666
668
  <td>
667
669
  <pre class="code"><span class="info file"># File 'lib/minting/mint/registry/zeros.rb', line 11</span>
@@ -669,9 +671,11 @@
669
671
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_zero_for'>zero_for</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
670
672
  <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'>Expect a Currency param. (</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> <span class='kw'>unless</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='rparen'>)</span>
671
673
 
674
+ <span class='kw'>return</span> <span class='ivar'>@zeros</span><span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='ivar'>@zeros</span><span class='op'>&amp;.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
675
+
672
676
  <span class='const'>MUTEX</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='kw'>do</span>
673
677
  <span class='ivar'>@zeros</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
674
- <span class='ivar'>@zeros</span><span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:new</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
678
+ <span class='ivar'>@zeros</span><span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:new</span><span class='comma'>,</span> <span class='rational'>0r</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
675
679
  <span class='kw'>end</span>
676
680
  <span class='kw'>end</span></pre>
677
681
  </td>
@@ -849,7 +853,7 @@
849
853
  </div>
850
854
 
851
855
  <div id="footer">
852
- Generated on Tue Jun 16 20:22:19 2026 by
856
+ Generated on Mon Jun 22 16:47:02 2026 by
853
857
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
854
858
  0.9.44 (ruby-4.0.5).
855
859
  </div>
@@ -254,7 +254,8 @@
254
254
  <strong>This method is part of a private API.</strong>
255
255
  You should avoid using this method if possible, as it may be removed or be changed in the future.
256
256
  </p>
257
- <p>Rounds <code>amount</code> to <code>ndigits</code> using the currently scoped rounding mode.</p>
257
+ <p>Rounds <code>amount</code> to <code>ndigits</code> using the currently scoped rounding mode.
258
+ Uses the fast path (+to_r.round+) when no custom mode is active.</p>
258
259
 
259
260
  </div>
260
261
  </div>
@@ -306,15 +307,25 @@
306
307
  <pre class="lines">
307
308
 
308
309
 
309
- 31
310
310
  32
311
- 33</pre>
311
+ 33
312
+ 34
313
+ 35
314
+ 36
315
+ 37
316
+ 38
317
+ 39</pre>
312
318
  </td>
313
319
  <td>
314
- <pre class="code"><span class="info file"># File 'lib/minting/mint/rounding.rb', line 31</span>
320
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/rounding.rb', line 32</span>
315
321
 
316
322
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_apply'>apply</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span>
317
- <span class='const'><span class='object_link'><a href="#MODES-constant" title="Mint::Rounding::MODES (constant)">MODES</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_current_mode'>current_mode</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_r'>to_r</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span>
323
+ <span class='id identifier rubyid_mode'>mode</span> <span class='op'>=</span> <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:minting_rounding_mode</span><span class='rbracket'>]</span>
324
+ <span class='kw'>if</span> <span class='id identifier rubyid_mode'>mode</span>
325
+ <span class='const'><span class='object_link'><a href="#MODES-constant" title="Mint::Rounding::MODES (constant)">MODES</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_r'>to_r</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span>
326
+ <span class='kw'>else</span>
327
+ <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_r'>to_r</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span>
328
+ <span class='kw'>end</span>
318
329
  <span class='kw'>end</span></pre>
319
330
  </td>
320
331
  </tr>
@@ -453,18 +464,18 @@ previous mode on exit (even on exception).</p>
453
464
  <pre class="lines">
454
465
 
455
466
 
456
- 41
457
- 42
458
- 43
459
- 44
460
- 45
461
- 46
462
467
  47
463
468
  48
464
- 49</pre>
469
+ 49
470
+ 50
471
+ 51
472
+ 52
473
+ 53
474
+ 54
475
+ 55</pre>
465
476
  </td>
466
477
  <td>
467
- <pre class="code"><span class="info file"># File 'lib/minting/mint/rounding.rb', line 41</span>
478
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/rounding.rb', line 47</span>
468
479
 
469
480
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_with_mode'>with_mode</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='rparen'>)</span>
470
481
  <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'>Unknown rounding mode: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mode'>mode</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='const'><span class='object_link'><a href="#MODES-constant" title="Mint::Rounding::MODES (constant)">MODES</a></span></span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='rparen'>)</span>
@@ -485,7 +496,7 @@ previous mode on exit (even on exception).</p>
485
496
  </div>
486
497
 
487
498
  <div id="footer">
488
- Generated on Tue Jun 16 20:22:19 2026 by
499
+ Generated on Mon Jun 22 16:47:02 2026 by
489
500
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
490
501
  0.9.44 (ruby-4.0.5).
491
502
  </div>
@@ -126,7 +126,7 @@
126
126
  </div>
127
127
 
128
128
  <div id="footer">
129
- Generated on Tue Jun 16 20:22:19 2026 by
129
+ Generated on Mon Jun 22 16:47:02 2026 by
130
130
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
131
131
  0.9.44 (ruby-4.0.5).
132
132
  </div>
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/mint.rb<span class="defines">,<br>
94
- lib/minting/money/clamp.rb,<br> lib/minting/money/money.rb,<br> lib/minting/mint/rounding.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>
93
+ <dd>lib/minting/mint/i18n.rb<span class="defines">,<br>
94
+ lib/minting/mint/mint.rb,<br> lib/minting/money/clamp.rb,<br> lib/minting/money/money.rb,<br> lib/minting/mint/rounding.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/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>
@@ -382,7 +382,7 @@ corresponding parameter is not explicitly provided.</p>
382
382
  29</pre>
383
383
  </td>
384
384
  <td>
385
- <pre class="code"><span class="info file"># File 'lib/minting/mint/locale_backend.rb', line 27</span>
385
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/i18n.rb', line 27</span>
386
386
 
387
387
  <span class='kw'>def</span> <span class='id identifier rubyid_locale_backend'>locale_backend</span>
388
388
  <span class='ivar'>@locale_backend</span>
@@ -580,6 +580,11 @@ corresponding parameter is not explicitly provided.</p>
580
580
  construction, parsing, change, allocation, and split operations.</p>
581
581
  <p>Restores the previous mode (or default) when the block exits, even on
582
582
  exception.</p>
583
+ <p>Rounding-mode support is loaded lazily on first call. Once loaded,
584
+ <code>Currency#normalize_amount</code> is patched to dispatch through the
585
+ rounding module, adding ~10โ€“35&amp;ns of overhead to every money creation
586
+ or mutation. When rounding modes are never used (the common case),
587
+ the fast path incurs zero overhead.</p>
583
588
 
584
589
  </div>
585
590
  </div>
@@ -643,12 +648,18 @@ exception.</p>
643
648
  <pre class="lines">
644
649
 
645
650
 
646
- 31</pre>
651
+ 37
652
+ 38
653
+ 39
654
+ 40</pre>
647
655
  </td>
648
656
  <td>
649
- <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 31</span>
657
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/mint.rb', line 37</span>
650
658
 
651
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_with_rounding'>with_rounding</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Mint/Rounding.html" title="Mint::Rounding (module)">Rounding</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with_mode'><span class='object_link'><a href="Mint/Rounding.html#with_mode-class_method" title="Mint::Rounding.with_mode (method)">with_mode</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='rparen'>)</span></pre>
659
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_with_rounding'>with_rounding</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='rparen'>)</span>
660
+ <span class='id identifier rubyid_require_relative'>require_relative</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>rounding</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Rounding.html" title="Mint::Rounding (module)">Rounding</a></span></span><span class='rparen'>)</span>
661
+ <span class='const'><span class='object_link'><a href="Mint/Rounding.html" title="Mint::Rounding (module)">Rounding</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with_mode'><span class='object_link'><a href="Mint/Rounding.html#with_mode-class_method" title="Mint::Rounding.with_mode (method)">with_mode</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='rparen'>)</span>
662
+ <span class='kw'>end</span></pre>
652
663
  </td>
653
664
  </tr>
654
665
  </table>
@@ -983,7 +994,7 @@ exception.</p>
983
994
  </div>
984
995
 
985
996
  <div id="footer">
986
- Generated on Tue Jun 16 20:22:19 2026 by
997
+ Generated on Mon Jun 22 16:47:02 2026 by
987
998
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
988
999
  0.9.44 (ruby-4.0.5).
989
1000
  </div>
data/doc/Minting.html CHANGED
@@ -116,7 +116,7 @@
116
116
 
117
117
  </div>
118
118
  </dt>
119
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.7.3</span><span class='tstring_end'>&#39;</span></span></pre></dd>
119
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.8.2</span><span class='tstring_end'>&#39;</span></span></pre></dd>
120
120
 
121
121
  </dl>
122
122
 
@@ -132,7 +132,7 @@
132
132
  </div>
133
133
 
134
134
  <div id="footer">
135
- Generated on Tue Jun 16 20:22:19 2026 by
135
+ Generated on Mon Jun 22 16:47:02 2026 by
136
136
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
137
137
  0.9.44 (ruby-4.0.5).
138
138
  </div>
data/doc/_index.html CHANGED
@@ -170,7 +170,7 @@
170
170
  </div>
171
171
 
172
172
  <div id="footer">
173
- Generated on Tue Jun 16 20:22:19 2026 by
173
+ Generated on Mon Jun 22 16:47:01 2026 by
174
174
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
175
175
  0.9.44 (ruby-4.0.5).
176
176
  </div>
data/doc/file.README.html CHANGED
@@ -64,7 +64,6 @@
64
64
  <p><a href="https://badge.fury.io/rb/minting"><img src="https://badge.fury.io/rb/minting.svg" alt="Gem Version" /></a>
65
65
  <a href="https://github.com/gferraz/minting/actions/workflows/ci.yml"><img src="https://github.com/gferraz/minting/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
66
66
  <a href="https://github.com/gferraz/minting"><img src="https://img.shields.io/badge/coverage-100%25-brightgreen" alt="Test Coverage" /></a>
67
- [![RubyCritic](<a href="https://img.shields.io/badge/RubyCritic-94gem">https://img.shields.io/badge/RubyCritic-94gem</a> /100-brightgreen)](<a href="https://github.com/gferraz/minting">https://github.com/gferraz/minting</a>)
68
67
  <a href="https://www.rubydoc.info/gems/minting/frames"><img src="https://img.shields.io/badge/docs-rubydoc.info-blue" alt="Documentation" /></a></p>
69
68
  <h2 id="Quick_start">Quick start</h2>
70
69
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>minting</span><span class='tstring_end'>&#39;</span></span>
@@ -76,49 +75,18 @@
76
75
  <span class='id identifier rubyid_total'>total</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='comment'>#=&gt; &quot;$21.59&quot;
77
76
  </span><span class='id identifier rubyid_total'>total</span><span class='period'>.</span><span class='id identifier rubyid_currency_code'>currency_code</span> <span class='comment'>#=&gt; &quot;USD&quot;
78
77
  </span></code></pre>
79
- <h2 id="Why_Minting_">Why Minting?</h2>
80
- <table>
81
- <thead>
82
- <tr>
83
- <th></th>
84
- <th>Minting</th>
85
- </tr>
86
- </thead>
87
- <tbody>
88
- <tr>
89
- <td><strong>Precision</strong></td>
90
- <td>Rational-based, zero floating-point error</td>
91
- </tr>
92
- <tr>
93
- <td><strong>Performance</strong></td>
94
- <td><strong>2ร— faster</strong> (10ร—+ formatting)</td>
95
- </tr>
96
- <tr>
97
- <td><strong>Ruby support</strong></td>
98
- <td>3.3+ (including Ruby 4.0)</td>
99
- </tr>
100
- <tr>
101
- <td><strong>Rails</strong></td>
102
- <td>Dedicated companion gem</td>
103
- </tr>
104
- <tr>
105
- <td><strong>Code quality</strong></td>
106
- <td>100% coverage, 93/100 RubyCritic</td>
107
- </tr>
108
- </tbody>
109
- </table>
110
- <h3 id="__Exact_precision">๐ŸŽฏ Exact precision</h3>
78
+ <h3 id="Exact_precision">Exact precision</h3>
111
79
  <p>Amounts are stored as <code>Rational</code> and rounded to the currency subunit. No floating-point surprises, ever.</p>
112
- <h3 id="__Blazing_performance">โšก Blazing performance</h3>
113
- <p>Minting is <strong>2ร— faster</strong> than the Money gem for everyday operations and <strong>over 10ร— faster for formatting</strong>. See full benchmarks in the <a href="test/performance/README.md">Performance Guide</a>.</p>
114
- <h3 id="__Clean__modern_API">๐Ÿงผ Clean, modern API</h3>
80
+ <h3 id="Blazing_performance">Blazing performance</h3>
81
+ <p>Minting is faster than the Money gem for everyday operations and <strong>over 10ร— faster for formatting</strong>. See full benchmarks in the <a href="test/performance/README.md">Performance Guide</a>.</p>
82
+ <h3 id="Clean__modern_API">Clean, modern API</h3>
115
83
  <p>Intuitive interface, descriptive error messages, and sensible defaults. Works the way you expect.</p>
116
- <h3 id="__Rails_ready">๐Ÿš† Rails-ready</h3>
84
+ <h3 id="Rails_ready">Rails-ready</h3>
117
85
  <p>Use with the <a href="https://github.com/gferraz/minting-rails">minting-rails</a> companion gem for drop-in ActiveRecord type casting, validators, and form helpers.</p>
118
- <h3 id="__Quality_you_can_trust">๐Ÿ† Quality you can trust</h3>
86
+ <h3 id="Quality_code">Quality code</h3>
119
87
  <ul>
120
88
  <li><strong>100% test coverage</strong> โ€” every line exercised</li>
121
- <li><strong>93/100 RubyCritic score</strong> โ€” clean, maintainable code</li>
89
+ <li><strong>94/100 RubyCritic score</strong> โ€” clean, maintainable code</li>
122
90
  <li><strong>CI-tested on Ruby 3.3 and 4.0</strong></li>
123
91
  </ul>
124
92
  <h2 id="Installation">Installation</h2>
@@ -172,6 +140,11 @@
172
140
  </span>
173
141
  <span class='id identifier rubyid_price_in_euros'>price_in_euros</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;symbol&gt;2s%&lt;amount&gt;+10f</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot; โ‚ฌ +12.34&quot;
174
142
  </span>
143
+ <span class='comment'># Integral &amp; fractional parts
144
+ </span><span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;integral&gt;d %&lt;fractional&gt;d/100</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot;9 99/100&quot;
145
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='float'>0.99</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'><span class='object_link'><a href="Mint/Money.html#to_s-instance_method" title="Mint::Money#to_s (method)">to_s</a></span></span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;integral&gt;d dollars and %&lt;fractional&gt;02d cents</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
146
+ <span class='comment'>#=&gt; &quot;0 dollars and 99 cents&quot;
147
+ </span>
175
148
  <span class='comment'># Per-sign Hash format (e.g. accounting parentheses for losses)
176
149
  </span><span class='id identifier rubyid_loss'>loss</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='op'>-</span><span class='float'>1234.56</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
177
150
  <span class='id identifier rubyid_loss'>loss</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>negative:</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> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot;($1,234.56)&quot;
@@ -191,9 +164,15 @@
191
164
 
192
165
  <span class='comment'># Fractional units (inverse of #fractional) - exact integer arithmetic
193
166
  </span>
194
- <span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_fractional'>fractional</span> <span class='comment'>#=&gt; 999
195
- </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_fractional'><span class='object_link'><a href="Mint/Money.html#from_fractional-class_method" title="Mint::Money.from_fractional (method)">from_fractional</a></span></span><span class='lparen'>(</span><span class='int'>999</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [USD 9.99]
196
- </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_fractional'><span class='object_link'><a href="Mint/Money.html#from_fractional-class_method" title="Mint::Money.from_fractional (method)">from_fractional</a></span></span><span class='lparen'>(</span><span class='int'>1234</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>JPY</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [JPY 1234] # subunit 0 -&gt; no scaling
167
+ <span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_subunits'>subunits</span> <span class='comment'>#=&gt; 999
168
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_subunits'><span class='object_link'><a href="Mint/Money.html#from_subunits-class_method" title="Mint::Money.from_subunits (method)">from_subunits</a></span></span><span class='lparen'>(</span><span class='int'>999</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [USD 9.99]
169
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_subunits'><span class='object_link'><a href="Mint/Money.html#from_subunits-class_method" title="Mint::Money.from_subunits (method)">from_subunits</a></span></span><span class='lparen'>(</span><span class='int'>1234</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>JPY</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [JPY 1234] # subunit 0 -&gt; no scaling
170
+ </span>
171
+
172
+ <span class='comment'># No currency (ISO 4217 XXX)
173
+ </span>
174
+ <span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_no_currency'><span class='object_link'><a href="Mint/Money.html#no_currency-class_method" title="Mint::Money.no_currency (method)">no_currency</a></span></span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='comment'>#=&gt; [XXX 100]
175
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_no_currency'><span class='object_link'><a href="Mint/Money.html#no_currency-class_method" title="Mint::Money.no_currency (method)">no_currency</a></span></span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span> <span class='comment'>#=&gt; [XXX 0]
197
176
  </span>
198
177
 
199
178
  <span class='comment'># Proportional allocation and split
@@ -230,7 +209,7 @@
230
209
  <li>Pass a currency code when the string has no symbol or code.</li>
231
210
  <li><code>1,234</code> means 1234, not 1.234 and <code>1,23</code> means 1.23, not 123</li>
232
211
  <li><code>1,234.00</code> is unambiguous (thousands + decimal).</li>
233
- <li>Accounting negatives like <code>($1.23)</code> are unsupported for now.</li>
212
+ <li>Accounting negatives like <code>($1.23)</code> or <code>(USD 10.00)</code> are supported โ€” the parser detects parentheses and negates the amount.</li>
234
213
  <li>Ambiguous symbols like <code>$</code> resolve by currency priority (currently USD).</li>
235
214
  <li>The parser scans all uppercase words for registered codes, so spurious non-currency words before the real code are correctly ignored: <code>Mint.parse(&quot;MAX 10.00 USD&quot;)</code> yields <code>[USD 10.00]</code>.</li>
236
215
  </ul>
@@ -252,11 +231,14 @@
252
231
  </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with_rounding'><span class='object_link'><a href="Mint.html#with_rounding-class_method" title="Mint.with_rounding (method)">with_rounding</a></span></span><span class='lparen'>(</span><span class='symbol'>:floor</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_parse'><span class='object_link'><a href="Mint.html#parse-instance_method" title="Mint#parse (method)">parse</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.009</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='comment'>#=&gt; [USD 1.00]
253
232
  </span></code></pre>
254
233
  <p>Modes: <code>:half_up</code> (default), <code>:half_down</code>, <code>:floor</code>, <code>:ceil</code>, <code>:truncate</code>, <code>:down</code>. Applies to construction, parsing, <code>change</code>, <code>split</code>, and <code>allocate</code>. Restores the previous mode when the block exits, even on exception.</p>
234
+ <blockquote>
235
+ <p><strong>Performance note:</strong> Rounding-mode support is not loaded by default โ€” <code>require 'minting'</code> uses the fastest possible rounding (equivalent to <code>:half_up</code>) with zero dispatch overhead. The first call to <code>Mint.with_rounding</code> loads the rounding module and patches <code>Currency#normalize_amount</code>, adding ~10โ€“35โ€ฏns per money creation or mutation. If your application never uses custom rounding modes (the common case), there is <strong>no performance cost</strong>.</p>
236
+ </blockquote>
255
237
  <p><strong>Refinements</strong> โ€” <code>10.dollars</code> and similar helpers require <code>using Mint</code> in the current scope (see Usage above).</p>
256
238
  <p><strong>Division</strong> โ€” <code>money / 5</code> returns new <code>Money</code>; <code>money / other_money</code> returns a numeric ratio, not money.</p>
257
239
  <p><strong>Zero equality</strong> โ€” Any zero amount is considered equal across currencies and to numeric zero (<code>Mint.money(0, 'USD') == Mint.money(0, 'EUR')</code> is intentionally <code>true</code>). Non-zero amounts must match currency and value.</p>
258
240
  <p><strong>Zero helper</strong> โ€” <code>Currency.zero('USD')</code> returns a frozen zero-Money, useful as a default value for discounts, totals, or counters.</p>
259
- <p><strong>Registered currencies</strong> โ€” <code>Currency.register(code:, subunit:, symbol:, priority:)</code> adds custom currencies. Only registered codes and symbols are recognized by the parser.</p>
241
+ <p><strong>Registered currencies</strong> โ€” <code>Currency.register(code:, subunit:, symbol:, priority:)</code> adds custom currencies. Only registered codes and symbols are recognized by the parser or searches. Nonetheless, you don't need to register a currency to use it with most of the features.</p>
260
242
  <p><strong>Built-in currencies</strong> โ€” 150+ ISO-4217 world currencies ship in <code>lib/minting/data/currencies.yaml</code> and load when the registry is first accessed.</p>
261
243
  <h2 id="Optional_top_level__Money__and__Currency_">Optional top-level <code>Money</code> and <code>Currency</code></h2>
262
244
  <p>By default, Minting keeps everything namespaced under <code>Mint</code> to coexist nicely with other gems. If you prefer shorter constants, opt in:</p>
@@ -279,14 +261,13 @@
279
261
  <strong>Not recommended:</strong> Reusable gems/libraries โ€” stick to <code>Mint::Money</code> to avoid conflicts.</p>
280
262
  <h2 id="Roadmap">Roadmap</h2>
281
263
  <ul>
282
- <li>Localization (I18n-aware formatting)</li>
283
264
  <li>Exchange-rate conversion infrastructure</li>
284
265
  </ul>
285
266
  <h2 id="License">License</h2>
286
267
  <p>MIT</p></div></div>
287
268
 
288
269
  <div id="footer">
289
- Generated on Tue Jun 16 20:22:19 2026 by
270
+ Generated on Mon Jun 22 16:47:02 2026 by
290
271
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
291
272
  0.9.44 (ruby-4.0.5).
292
273
  </div>
data/doc/index.html CHANGED
@@ -64,7 +64,6 @@
64
64
  <p><a href="https://badge.fury.io/rb/minting"><img src="https://badge.fury.io/rb/minting.svg" alt="Gem Version" /></a>
65
65
  <a href="https://github.com/gferraz/minting/actions/workflows/ci.yml"><img src="https://github.com/gferraz/minting/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
66
66
  <a href="https://github.com/gferraz/minting"><img src="https://img.shields.io/badge/coverage-100%25-brightgreen" alt="Test Coverage" /></a>
67
- [![RubyCritic](<a href="https://img.shields.io/badge/RubyCritic-94gem">https://img.shields.io/badge/RubyCritic-94gem</a> /100-brightgreen)](<a href="https://github.com/gferraz/minting">https://github.com/gferraz/minting</a>)
68
67
  <a href="https://www.rubydoc.info/gems/minting/frames"><img src="https://img.shields.io/badge/docs-rubydoc.info-blue" alt="Documentation" /></a></p>
69
68
  <h2 id="Quick_start">Quick start</h2>
70
69
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>minting</span><span class='tstring_end'>&#39;</span></span>
@@ -76,49 +75,18 @@
76
75
  <span class='id identifier rubyid_total'>total</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='comment'>#=&gt; &quot;$21.59&quot;
77
76
  </span><span class='id identifier rubyid_total'>total</span><span class='period'>.</span><span class='id identifier rubyid_currency_code'>currency_code</span> <span class='comment'>#=&gt; &quot;USD&quot;
78
77
  </span></code></pre>
79
- <h2 id="Why_Minting_">Why Minting?</h2>
80
- <table>
81
- <thead>
82
- <tr>
83
- <th></th>
84
- <th>Minting</th>
85
- </tr>
86
- </thead>
87
- <tbody>
88
- <tr>
89
- <td><strong>Precision</strong></td>
90
- <td>Rational-based, zero floating-point error</td>
91
- </tr>
92
- <tr>
93
- <td><strong>Performance</strong></td>
94
- <td><strong>2ร— faster</strong> (10ร—+ formatting)</td>
95
- </tr>
96
- <tr>
97
- <td><strong>Ruby support</strong></td>
98
- <td>3.3+ (including Ruby 4.0)</td>
99
- </tr>
100
- <tr>
101
- <td><strong>Rails</strong></td>
102
- <td>Dedicated companion gem</td>
103
- </tr>
104
- <tr>
105
- <td><strong>Code quality</strong></td>
106
- <td>100% coverage, 93/100 RubyCritic</td>
107
- </tr>
108
- </tbody>
109
- </table>
110
- <h3 id="__Exact_precision">๐ŸŽฏ Exact precision</h3>
78
+ <h3 id="Exact_precision">Exact precision</h3>
111
79
  <p>Amounts are stored as <code>Rational</code> and rounded to the currency subunit. No floating-point surprises, ever.</p>
112
- <h3 id="__Blazing_performance">โšก Blazing performance</h3>
113
- <p>Minting is <strong>2ร— faster</strong> than the Money gem for everyday operations and <strong>over 10ร— faster for formatting</strong>. See full benchmarks in the <a href="test/performance/README.md">Performance Guide</a>.</p>
114
- <h3 id="__Clean__modern_API">๐Ÿงผ Clean, modern API</h3>
80
+ <h3 id="Blazing_performance">Blazing performance</h3>
81
+ <p>Minting is faster than the Money gem for everyday operations and <strong>over 10ร— faster for formatting</strong>. See full benchmarks in the <a href="test/performance/README.md">Performance Guide</a>.</p>
82
+ <h3 id="Clean__modern_API">Clean, modern API</h3>
115
83
  <p>Intuitive interface, descriptive error messages, and sensible defaults. Works the way you expect.</p>
116
- <h3 id="__Rails_ready">๐Ÿš† Rails-ready</h3>
84
+ <h3 id="Rails_ready">Rails-ready</h3>
117
85
  <p>Use with the <a href="https://github.com/gferraz/minting-rails">minting-rails</a> companion gem for drop-in ActiveRecord type casting, validators, and form helpers.</p>
118
- <h3 id="__Quality_you_can_trust">๐Ÿ† Quality you can trust</h3>
86
+ <h3 id="Quality_code">Quality code</h3>
119
87
  <ul>
120
88
  <li><strong>100% test coverage</strong> โ€” every line exercised</li>
121
- <li><strong>93/100 RubyCritic score</strong> โ€” clean, maintainable code</li>
89
+ <li><strong>94/100 RubyCritic score</strong> โ€” clean, maintainable code</li>
122
90
  <li><strong>CI-tested on Ruby 3.3 and 4.0</strong></li>
123
91
  </ul>
124
92
  <h2 id="Installation">Installation</h2>
@@ -172,6 +140,11 @@
172
140
  </span>
173
141
  <span class='id identifier rubyid_price_in_euros'>price_in_euros</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;symbol&gt;2s%&lt;amount&gt;+10f</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot; โ‚ฌ +12.34&quot;
174
142
  </span>
143
+ <span class='comment'># Integral &amp; fractional parts
144
+ </span><span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;integral&gt;d %&lt;fractional&gt;d/100</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot;9 99/100&quot;
145
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='float'>0.99</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'><span class='object_link'><a href="Mint/Money.html#to_s-instance_method" title="Mint::Money#to_s (method)">to_s</a></span></span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>%&lt;integral&gt;d dollars and %&lt;fractional&gt;02d cents</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
146
+ <span class='comment'>#=&gt; &quot;0 dollars and 99 cents&quot;
147
+ </span>
175
148
  <span class='comment'># Per-sign Hash format (e.g. accounting parentheses for losses)
176
149
  </span><span class='id identifier rubyid_loss'>loss</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='op'>-</span><span class='float'>1234.56</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
177
150
  <span class='id identifier rubyid_loss'>loss</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>negative:</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> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>#=&gt; &quot;($1,234.56)&quot;
@@ -191,9 +164,15 @@
191
164
 
192
165
  <span class='comment'># Fractional units (inverse of #fractional) - exact integer arithmetic
193
166
  </span>
194
- <span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_fractional'>fractional</span> <span class='comment'>#=&gt; 999
195
- </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_fractional'><span class='object_link'><a href="Mint/Money.html#from_fractional-class_method" title="Mint::Money.from_fractional (method)">from_fractional</a></span></span><span class='lparen'>(</span><span class='int'>999</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [USD 9.99]
196
- </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_fractional'><span class='object_link'><a href="Mint/Money.html#from_fractional-class_method" title="Mint::Money.from_fractional (method)">from_fractional</a></span></span><span class='lparen'>(</span><span class='int'>1234</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>JPY</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [JPY 1234] # subunit 0 -&gt; no scaling
167
+ <span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_subunits'>subunits</span> <span class='comment'>#=&gt; 999
168
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_subunits'><span class='object_link'><a href="Mint/Money.html#from_subunits-class_method" title="Mint::Money.from_subunits (method)">from_subunits</a></span></span><span class='lparen'>(</span><span class='int'>999</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [USD 9.99]
169
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_from_subunits'><span class='object_link'><a href="Mint/Money.html#from_subunits-class_method" title="Mint::Money.from_subunits (method)">from_subunits</a></span></span><span class='lparen'>(</span><span class='int'>1234</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>JPY</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'>#=&gt; [JPY 1234] # subunit 0 -&gt; no scaling
170
+ </span>
171
+
172
+ <span class='comment'># No currency (ISO 4217 XXX)
173
+ </span>
174
+ <span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_no_currency'><span class='object_link'><a href="Mint/Money.html#no_currency-class_method" title="Mint::Money.no_currency (method)">no_currency</a></span></span><span class='lparen'>(</span><span class='int'>100</span><span class='rparen'>)</span> <span class='comment'>#=&gt; [XXX 100]
175
+ </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_no_currency'><span class='object_link'><a href="Mint/Money.html#no_currency-class_method" title="Mint::Money.no_currency (method)">no_currency</a></span></span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span> <span class='comment'>#=&gt; [XXX 0]
197
176
  </span>
198
177
 
199
178
  <span class='comment'># Proportional allocation and split
@@ -230,7 +209,7 @@
230
209
  <li>Pass a currency code when the string has no symbol or code.</li>
231
210
  <li><code>1,234</code> means 1234, not 1.234 and <code>1,23</code> means 1.23, not 123</li>
232
211
  <li><code>1,234.00</code> is unambiguous (thousands + decimal).</li>
233
- <li>Accounting negatives like <code>($1.23)</code> are unsupported for now.</li>
212
+ <li>Accounting negatives like <code>($1.23)</code> or <code>(USD 10.00)</code> are supported โ€” the parser detects parentheses and negates the amount.</li>
234
213
  <li>Ambiguous symbols like <code>$</code> resolve by currency priority (currently USD).</li>
235
214
  <li>The parser scans all uppercase words for registered codes, so spurious non-currency words before the real code are correctly ignored: <code>Mint.parse(&quot;MAX 10.00 USD&quot;)</code> yields <code>[USD 10.00]</code>.</li>
236
215
  </ul>
@@ -252,11 +231,14 @@
252
231
  </span><span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_with_rounding'><span class='object_link'><a href="Mint.html#with_rounding-class_method" title="Mint.with_rounding (method)">with_rounding</a></span></span><span class='lparen'>(</span><span class='symbol'>:floor</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='const'><span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_parse'><span class='object_link'><a href="Mint.html#parse-instance_method" title="Mint#parse (method)">parse</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.009</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>USD</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='comment'>#=&gt; [USD 1.00]
253
232
  </span></code></pre>
254
233
  <p>Modes: <code>:half_up</code> (default), <code>:half_down</code>, <code>:floor</code>, <code>:ceil</code>, <code>:truncate</code>, <code>:down</code>. Applies to construction, parsing, <code>change</code>, <code>split</code>, and <code>allocate</code>. Restores the previous mode when the block exits, even on exception.</p>
234
+ <blockquote>
235
+ <p><strong>Performance note:</strong> Rounding-mode support is not loaded by default โ€” <code>require 'minting'</code> uses the fastest possible rounding (equivalent to <code>:half_up</code>) with zero dispatch overhead. The first call to <code>Mint.with_rounding</code> loads the rounding module and patches <code>Currency#normalize_amount</code>, adding ~10โ€“35โ€ฏns per money creation or mutation. If your application never uses custom rounding modes (the common case), there is <strong>no performance cost</strong>.</p>
236
+ </blockquote>
255
237
  <p><strong>Refinements</strong> โ€” <code>10.dollars</code> and similar helpers require <code>using Mint</code> in the current scope (see Usage above).</p>
256
238
  <p><strong>Division</strong> โ€” <code>money / 5</code> returns new <code>Money</code>; <code>money / other_money</code> returns a numeric ratio, not money.</p>
257
239
  <p><strong>Zero equality</strong> โ€” Any zero amount is considered equal across currencies and to numeric zero (<code>Mint.money(0, 'USD') == Mint.money(0, 'EUR')</code> is intentionally <code>true</code>). Non-zero amounts must match currency and value.</p>
258
240
  <p><strong>Zero helper</strong> โ€” <code>Currency.zero('USD')</code> returns a frozen zero-Money, useful as a default value for discounts, totals, or counters.</p>
259
- <p><strong>Registered currencies</strong> โ€” <code>Currency.register(code:, subunit:, symbol:, priority:)</code> adds custom currencies. Only registered codes and symbols are recognized by the parser.</p>
241
+ <p><strong>Registered currencies</strong> โ€” <code>Currency.register(code:, subunit:, symbol:, priority:)</code> adds custom currencies. Only registered codes and symbols are recognized by the parser or searches. Nonetheless, you don't need to register a currency to use it with most of the features.</p>
260
242
  <p><strong>Built-in currencies</strong> โ€” 150+ ISO-4217 world currencies ship in <code>lib/minting/data/currencies.yaml</code> and load when the registry is first accessed.</p>
261
243
  <h2 id="Optional_top_level__Money__and__Currency_">Optional top-level <code>Money</code> and <code>Currency</code></h2>
262
244
  <p>By default, Minting keeps everything namespaced under <code>Mint</code> to coexist nicely with other gems. If you prefer shorter constants, opt in:</p>
@@ -279,14 +261,13 @@
279
261
  <strong>Not recommended:</strong> Reusable gems/libraries โ€” stick to <code>Mint::Money</code> to avoid conflicts.</p>
280
262
  <h2 id="Roadmap">Roadmap</h2>
281
263
  <ul>
282
- <li>Localization (I18n-aware formatting)</li>
283
264
  <li>Exchange-rate conversion infrastructure</li>
284
265
  </ul>
285
266
  <h2 id="License">License</h2>
286
267
  <p>MIT</p></div></div>
287
268
 
288
269
  <div id="footer">
289
- Generated on Tue Jun 16 20:22:19 2026 by
270
+ Generated on Mon Jun 22 16:47:01 2026 by
290
271
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
291
272
  0.9.44 (ruby-4.0.5).
292
273
  </div>