minting 1.7.3 → 1.8.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.
- checksums.yaml +4 -4
- data/README.md +25 -8
- data/doc/Mint/Currency.html +535 -18
- data/doc/Mint/Money.html +659 -185
- data/doc/Mint/RangeStepPatch.html +1 -1
- data/doc/Mint/Registry.html +19 -2
- data/doc/Mint/Rounding.html +495 -0
- data/doc/Mint/UnknownCurrency.html +1 -1
- data/doc/Mint.html +187 -399
- data/doc/Minting.html +2 -2
- data/doc/_index.html +8 -1
- data/doc/agents/api_review-2026-06-15.md +0 -13
- data/doc/agents/copilot-instructions.md +70 -0
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +19 -9
- data/doc/index.html +19 -9
- data/doc/method_list.html +130 -42
- data/doc/top-level-namespace.html +1 -1
- data/lib/minting/currency/currency.rb +41 -2
- data/lib/minting/mint/dsl/range.rb +1 -0
- data/lib/minting/mint/mint.rb +10 -37
- data/lib/minting/mint/parser/parser.rb +50 -15
- data/lib/minting/mint/parser/separators.rb +10 -8
- data/lib/minting/mint/registry/zeros.rb +2 -0
- data/lib/minting/mint/rounding.rb +51 -0
- data/lib/minting/mint.rb +1 -0
- data/lib/minting/money/allocation/allocation.rb +1 -2
- data/lib/minting/money/allocation/split.rb +1 -1
- data/lib/minting/money/arithmetics/methods.rb +2 -2
- data/lib/minting/money/arithmetics/operators.rb +6 -6
- data/lib/minting/money/clamp.rb +1 -1
- data/lib/minting/money/coercion.rb +1 -1
- data/lib/minting/money/comparable.rb +6 -0
- data/lib/minting/money/constructors.rb +60 -12
- data/lib/minting/money/money.rb +0 -6
- data/lib/minting/version.rb +1 -1
- metadata +4 -1
data/doc/Mint/Currency.html
CHANGED
|
@@ -334,6 +334,72 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
334
334
|
<li class="public ">
|
|
335
335
|
<span class="summary_signature">
|
|
336
336
|
|
|
337
|
+
<a href="#for_code-class_method" title="for_code (class method)">.<strong>for_code</strong>(code) ⇒ Currency<sup>?</sup> </a>
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
</span>
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
<span class="summary_desc"><div class='inline'><p>Looks up a registered currency by its alpha code.</p></div></span>
|
|
352
|
+
|
|
353
|
+
</li>
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
<li class="public ">
|
|
357
|
+
<span class="summary_signature">
|
|
358
|
+
|
|
359
|
+
<a href="#for_symbol-class_method" title="for_symbol (class method)">.<strong>for_symbol</strong>(symbol) ⇒ Currency<sup>?</sup> </a>
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
</span>
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
<span class="summary_desc"><div class='inline'><p>Looks up a currency by its display symbol.</p></div></span>
|
|
374
|
+
|
|
375
|
+
</li>
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
<li class="public ">
|
|
379
|
+
<span class="summary_signature">
|
|
380
|
+
|
|
381
|
+
<a href="#register-class_method" title="register (class method)">.<strong>register</strong>(code:, subunit: 0, symbol: '', priority: 0) ⇒ Currency </a>
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
</span>
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
<span class="summary_desc"><div class='inline'><p>Registers a new currency, raising a KeyError if already registered.</p></div></span>
|
|
396
|
+
|
|
397
|
+
</li>
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
<li class="public ">
|
|
401
|
+
<span class="summary_signature">
|
|
402
|
+
|
|
337
403
|
<a href="#resolve-class_method" title="resolve (class method)">.<strong>resolve</strong>(object) ⇒ Currency<sup>?</sup> </a>
|
|
338
404
|
|
|
339
405
|
|
|
@@ -375,6 +441,28 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
375
441
|
</li>
|
|
376
442
|
|
|
377
443
|
|
|
444
|
+
<li class="public ">
|
|
445
|
+
<span class="summary_signature">
|
|
446
|
+
|
|
447
|
+
<a href="#zero-class_method" title="zero (class method)">.<strong>zero</strong>(currency) ⇒ Money </a>
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
</span>
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
<span class="summary_desc"><div class='inline'><p>Returns a zero <span class='object_link'><a href="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>
|
|
462
|
+
|
|
463
|
+
</li>
|
|
464
|
+
|
|
465
|
+
|
|
378
466
|
</ul>
|
|
379
467
|
|
|
380
468
|
|
|
@@ -475,6 +563,28 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
475
563
|
</li>
|
|
476
564
|
|
|
477
565
|
|
|
566
|
+
<li class="public ">
|
|
567
|
+
<span class="summary_signature">
|
|
568
|
+
|
|
569
|
+
<a href="#zero-instance_method" title="#zero (instance method)">#<strong>zero</strong> ⇒ Object </a>
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
</span>
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
584
|
+
|
|
585
|
+
</li>
|
|
586
|
+
|
|
587
|
+
|
|
478
588
|
</ul>
|
|
479
589
|
|
|
480
590
|
|
|
@@ -1038,7 +1148,302 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1038
1148
|
|
|
1039
1149
|
|
|
1040
1150
|
<div class="method_details first">
|
|
1041
|
-
<h3 class="signature first" id="
|
|
1151
|
+
<h3 class="signature first" id="for_code-class_method">
|
|
1152
|
+
|
|
1153
|
+
.<strong>for_code</strong>(code) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
</h3><div class="docstring">
|
|
1160
|
+
<div class="discussion">
|
|
1161
|
+
<p>Looks up a registered currency by its alpha code.</p>
|
|
1162
|
+
|
|
1163
|
+
</div>
|
|
1164
|
+
</div>
|
|
1165
|
+
<div class="tags">
|
|
1166
|
+
<p class="tag_title">Parameters:</p>
|
|
1167
|
+
<ul class="param">
|
|
1168
|
+
|
|
1169
|
+
<li>
|
|
1170
|
+
|
|
1171
|
+
<span class='name'>code</span>
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
—
|
|
1179
|
+
<div class='inline'><p>the currency code</p></div>
|
|
1180
|
+
|
|
1181
|
+
</li>
|
|
1182
|
+
|
|
1183
|
+
</ul>
|
|
1184
|
+
|
|
1185
|
+
<p class="tag_title">Returns:</p>
|
|
1186
|
+
<ul class="return">
|
|
1187
|
+
|
|
1188
|
+
<li>
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
—
|
|
1196
|
+
<div class='inline'><p>the registered Currency, or <code>nil</code> if not found</p></div>
|
|
1197
|
+
|
|
1198
|
+
</li>
|
|
1199
|
+
|
|
1200
|
+
</ul>
|
|
1201
|
+
|
|
1202
|
+
</div><table class="source_code">
|
|
1203
|
+
<tr>
|
|
1204
|
+
<td>
|
|
1205
|
+
<pre class="lines">
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
95
|
|
1209
|
+
96
|
|
1210
|
+
97</pre>
|
|
1211
|
+
</td>
|
|
1212
|
+
<td>
|
|
1213
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 95</span>
|
|
1214
|
+
|
|
1215
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_for_code'>for_code</span><span class='lparen'>(</span><span class='id identifier rubyid_code'>code</span><span class='rparen'>)</span>
|
|
1216
|
+
<span class='const'><span class='object_link'><a href="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="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>
|
|
1217
|
+
<span class='kw'>end</span></pre>
|
|
1218
|
+
</td>
|
|
1219
|
+
</tr>
|
|
1220
|
+
</table>
|
|
1221
|
+
</div>
|
|
1222
|
+
|
|
1223
|
+
<div class="method_details ">
|
|
1224
|
+
<h3 class="signature " id="for_symbol-class_method">
|
|
1225
|
+
|
|
1226
|
+
.<strong>for_symbol</strong>(symbol) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
</h3><div class="docstring">
|
|
1233
|
+
<div class="discussion">
|
|
1234
|
+
<p>Looks up a currency by its display symbol.</p>
|
|
1235
|
+
|
|
1236
|
+
</div>
|
|
1237
|
+
</div>
|
|
1238
|
+
<div class="tags">
|
|
1239
|
+
<p class="tag_title">Parameters:</p>
|
|
1240
|
+
<ul class="param">
|
|
1241
|
+
|
|
1242
|
+
<li>
|
|
1243
|
+
|
|
1244
|
+
<span class='name'>symbol</span>
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1248
|
+
|
|
1249
|
+
|
|
1250
|
+
|
|
1251
|
+
—
|
|
1252
|
+
<div class='inline'><p>the display symbol (e.g. "$", "R$")</p></div>
|
|
1253
|
+
|
|
1254
|
+
</li>
|
|
1255
|
+
|
|
1256
|
+
</ul>
|
|
1257
|
+
|
|
1258
|
+
<p class="tag_title">Returns:</p>
|
|
1259
|
+
<ul class="return">
|
|
1260
|
+
|
|
1261
|
+
<li>
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
—
|
|
1269
|
+
<div class='inline'><p>the highest-priority currency for the symbol</p></div>
|
|
1270
|
+
|
|
1271
|
+
</li>
|
|
1272
|
+
|
|
1273
|
+
</ul>
|
|
1274
|
+
|
|
1275
|
+
</div><table class="source_code">
|
|
1276
|
+
<tr>
|
|
1277
|
+
<td>
|
|
1278
|
+
<pre class="lines">
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
103
|
|
1282
|
+
104
|
|
1283
|
+
105</pre>
|
|
1284
|
+
</td>
|
|
1285
|
+
<td>
|
|
1286
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 103</span>
|
|
1287
|
+
|
|
1288
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_for_symbol'>for_symbol</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span>
|
|
1289
|
+
<span class='const'><span class='object_link'><a href="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="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>
|
|
1290
|
+
<span class='kw'>end</span></pre>
|
|
1291
|
+
</td>
|
|
1292
|
+
</tr>
|
|
1293
|
+
</table>
|
|
1294
|
+
</div>
|
|
1295
|
+
|
|
1296
|
+
<div class="method_details ">
|
|
1297
|
+
<h3 class="signature " id="register-class_method">
|
|
1298
|
+
|
|
1299
|
+
.<strong>register</strong>(code:, subunit: 0, symbol: '', priority: 0) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
</h3><div class="docstring">
|
|
1306
|
+
<div class="discussion">
|
|
1307
|
+
<p>Registers a new currency, raising a KeyError if already registered.</p>
|
|
1308
|
+
|
|
1309
|
+
</div>
|
|
1310
|
+
</div>
|
|
1311
|
+
<div class="tags">
|
|
1312
|
+
<p class="tag_title">Parameters:</p>
|
|
1313
|
+
<ul class="param">
|
|
1314
|
+
|
|
1315
|
+
<li>
|
|
1316
|
+
|
|
1317
|
+
<span class='name'>code</span>
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
—
|
|
1325
|
+
<div class='inline'><p>the unique currency code</p></div>
|
|
1326
|
+
|
|
1327
|
+
</li>
|
|
1328
|
+
|
|
1329
|
+
<li>
|
|
1330
|
+
|
|
1331
|
+
<span class='name'>subunit</span>
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
—
|
|
1341
|
+
<div class='inline'><p>the decimal subunit precision, defaults to 0</p></div>
|
|
1342
|
+
|
|
1343
|
+
</li>
|
|
1344
|
+
|
|
1345
|
+
<li>
|
|
1346
|
+
|
|
1347
|
+
<span class='name'>symbol</span>
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
<em class="default">(defaults to: <tt>''</tt>)</em>
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
—
|
|
1357
|
+
<div class='inline'><p>the display symbol</p></div>
|
|
1358
|
+
|
|
1359
|
+
</li>
|
|
1360
|
+
|
|
1361
|
+
<li>
|
|
1362
|
+
|
|
1363
|
+
<span class='name'>priority</span>
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
—
|
|
1373
|
+
<div class='inline'><p>parser precedence priority</p></div>
|
|
1374
|
+
|
|
1375
|
+
</li>
|
|
1376
|
+
|
|
1377
|
+
</ul>
|
|
1378
|
+
|
|
1379
|
+
<p class="tag_title">Returns:</p>
|
|
1380
|
+
<ul class="return">
|
|
1381
|
+
|
|
1382
|
+
<li>
|
|
1383
|
+
|
|
1384
|
+
|
|
1385
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
|
|
1389
|
+
—
|
|
1390
|
+
<div class='inline'><p>the newly registered Currency instance</p></div>
|
|
1391
|
+
|
|
1392
|
+
</li>
|
|
1393
|
+
|
|
1394
|
+
</ul>
|
|
1395
|
+
<p class="tag_title">Raises:</p>
|
|
1396
|
+
<ul class="raise">
|
|
1397
|
+
|
|
1398
|
+
<li>
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
—
|
|
1406
|
+
<div class='inline'><p>if the code contains invalid characters</p></div>
|
|
1407
|
+
|
|
1408
|
+
</li>
|
|
1409
|
+
|
|
1410
|
+
<li>
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
<span class='type'>(<tt>KeyError</tt>)</span>
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
—
|
|
1418
|
+
<div class='inline'><p>if the currency code is already registered</p></div>
|
|
1419
|
+
|
|
1420
|
+
</li>
|
|
1421
|
+
|
|
1422
|
+
</ul>
|
|
1423
|
+
|
|
1424
|
+
</div><table class="source_code">
|
|
1425
|
+
<tr>
|
|
1426
|
+
<td>
|
|
1427
|
+
<pre class="lines">
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
57
|
|
1431
|
+
58
|
|
1432
|
+
59</pre>
|
|
1433
|
+
</td>
|
|
1434
|
+
<td>
|
|
1435
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 57</span>
|
|
1436
|
+
|
|
1437
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_register'>register</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'>'</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='rparen'>)</span>
|
|
1438
|
+
<span class='const'><span class='object_link'><a href="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="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>
|
|
1439
|
+
<span class='kw'>end</span></pre>
|
|
1440
|
+
</td>
|
|
1441
|
+
</tr>
|
|
1442
|
+
</table>
|
|
1443
|
+
</div>
|
|
1444
|
+
|
|
1445
|
+
<div class="method_details ">
|
|
1446
|
+
<h3 class="signature " id="resolve-class_method">
|
|
1042
1447
|
|
|
1043
1448
|
.<strong>resolve</strong>(object) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
1044
1449
|
|
|
@@ -1114,25 +1519,25 @@ or the code is not registered</p></div>
|
|
|
1114
1519
|
<pre class="lines">
|
|
1115
1520
|
|
|
1116
1521
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1522
|
+
70
|
|
1523
|
+
71
|
|
1524
|
+
72
|
|
1525
|
+
73
|
|
1526
|
+
74
|
|
1527
|
+
75
|
|
1528
|
+
76
|
|
1529
|
+
77
|
|
1530
|
+
78</pre>
|
|
1126
1531
|
</td>
|
|
1127
1532
|
<td>
|
|
1128
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1533
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 70</span>
|
|
1129
1534
|
|
|
1130
1535
|
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
|
|
1131
1536
|
<span class='kw'>case</span> <span class='id identifier rubyid_object'>object</span>
|
|
1132
1537
|
<span class='kw'>when</span> <span class='const'>NilClass</span> <span class='kw'>then</span> <span class='kw'>nil</span>
|
|
1133
1538
|
<span class='kw'>when</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span> <span class='kw'>then</span> <span class='id identifier rubyid_object'>object</span>
|
|
1134
1539
|
<span class='kw'>when</span> <span class='const'><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></span> <span class='kw'>then</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_currency'>currency</span>
|
|
1135
|
-
<span class='kw'>when</span> <span class='const'>String</span> <span class='kw'>then</span> <span class='const'><span class='object_link'><a href="
|
|
1540
|
+
<span class='kw'>when</span> <span class='const'>String</span> <span class='kw'>then</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_for_code'><span class='object_link'><a href="#for_code-class_method" title="Mint::Currency.for_code (method)">for_code</a></span></span> <span class='id identifier rubyid_object'>object</span>
|
|
1136
1541
|
<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'>"</span><span class='tstring_content'>currency must be [Currency], [Money], [String] or nil (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span>
|
|
1137
1542
|
<span class='kw'>end</span>
|
|
1138
1543
|
<span class='kw'>end</span></pre>
|
|
@@ -1216,12 +1621,12 @@ or the code is not registered</p></div>
|
|
|
1216
1621
|
<pre class="lines">
|
|
1217
1622
|
|
|
1218
1623
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1624
|
+
87
|
|
1625
|
+
88
|
|
1626
|
+
89</pre>
|
|
1222
1627
|
</td>
|
|
1223
1628
|
<td>
|
|
1224
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1629
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 87</span>
|
|
1225
1630
|
|
|
1226
1631
|
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve!'>resolve!</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
|
|
1227
1632
|
<span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span> <span class='kw'>or</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'>"</span><span class='tstring_content'>Could not resolve (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='embexpr_end'>}</span><span class='tstring_content'>) into a currency</span><span class='tstring_end'>"</span></span>
|
|
@@ -1229,6 +1634,92 @@ or the code is not registered</p></div>
|
|
|
1229
1634
|
</td>
|
|
1230
1635
|
</tr>
|
|
1231
1636
|
</table>
|
|
1637
|
+
</div>
|
|
1638
|
+
|
|
1639
|
+
<div class="method_details ">
|
|
1640
|
+
<h3 class="signature " id="zero-class_method">
|
|
1641
|
+
|
|
1642
|
+
.<strong>zero</strong>(currency) ⇒ <tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
</h3><div class="docstring">
|
|
1649
|
+
<div class="discussion">
|
|
1650
|
+
<p>Returns a zero <span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span> in the given currency, useful as a default value
|
|
1651
|
+
for discounts, totals, or placeholders.</p>
|
|
1652
|
+
|
|
1653
|
+
</div>
|
|
1654
|
+
</div>
|
|
1655
|
+
<div class="tags">
|
|
1656
|
+
<p class="tag_title">Parameters:</p>
|
|
1657
|
+
<ul class="param">
|
|
1658
|
+
|
|
1659
|
+
<li>
|
|
1660
|
+
|
|
1661
|
+
<span class='name'>currency</span>
|
|
1662
|
+
|
|
1663
|
+
|
|
1664
|
+
<span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1665
|
+
|
|
1666
|
+
|
|
1667
|
+
|
|
1668
|
+
—
|
|
1669
|
+
<div class='inline'><p>a currency code or object</p></div>
|
|
1670
|
+
|
|
1671
|
+
</li>
|
|
1672
|
+
|
|
1673
|
+
</ul>
|
|
1674
|
+
|
|
1675
|
+
<p class="tag_title">Returns:</p>
|
|
1676
|
+
<ul class="return">
|
|
1677
|
+
|
|
1678
|
+
<li>
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
<span class='type'>(<tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>)</span>
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
—
|
|
1686
|
+
<div class='inline'><p>a frozen zero-Money</p></div>
|
|
1687
|
+
|
|
1688
|
+
</li>
|
|
1689
|
+
|
|
1690
|
+
</ul>
|
|
1691
|
+
<p class="tag_title">Raises:</p>
|
|
1692
|
+
<ul class="raise">
|
|
1693
|
+
|
|
1694
|
+
<li>
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
|
|
1701
|
+
—
|
|
1702
|
+
<div class='inline'><p>if the currency can't be resolved</p></div>
|
|
1703
|
+
|
|
1704
|
+
</li>
|
|
1705
|
+
|
|
1706
|
+
</ul>
|
|
1707
|
+
|
|
1708
|
+
</div><table class="source_code">
|
|
1709
|
+
<tr>
|
|
1710
|
+
<td>
|
|
1711
|
+
<pre class="lines">
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
113</pre>
|
|
1715
|
+
</td>
|
|
1716
|
+
<td>
|
|
1717
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 113</span>
|
|
1718
|
+
|
|
1719
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></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="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="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="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve!'><span class='object_link'><a href="#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>
|
|
1720
|
+
</td>
|
|
1721
|
+
</tr>
|
|
1722
|
+
</table>
|
|
1232
1723
|
</div>
|
|
1233
1724
|
|
|
1234
1725
|
</div>
|
|
@@ -1372,7 +1863,33 @@ or the code is not registered</p></div>
|
|
|
1372
1863
|
<td>
|
|
1373
1864
|
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 43</span>
|
|
1374
1865
|
|
|
1375
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_normalize_amount'>normalize_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='
|
|
1866
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_normalize_amount'>normalize_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</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="Rounding.html" title="Mint::Rounding (module)">Rounding</a></span></span><span class='period'>.</span><span class='id identifier rubyid_apply'><span class='object_link'><a href="Rounding.html#apply-class_method" title="Mint::Rounding.apply (method)">apply</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_subunit'>subunit</span><span class='rparen'>)</span></pre>
|
|
1867
|
+
</td>
|
|
1868
|
+
</tr>
|
|
1869
|
+
</table>
|
|
1870
|
+
</div>
|
|
1871
|
+
|
|
1872
|
+
<div class="method_details ">
|
|
1873
|
+
<h3 class="signature " id="zero-instance_method">
|
|
1874
|
+
|
|
1875
|
+
#<strong>zero</strong> ⇒ <tt>Object</tt>
|
|
1876
|
+
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
</h3><table class="source_code">
|
|
1882
|
+
<tr>
|
|
1883
|
+
<td>
|
|
1884
|
+
<pre class="lines">
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
45</pre>
|
|
1888
|
+
</td>
|
|
1889
|
+
<td>
|
|
1890
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 45</span>
|
|
1891
|
+
|
|
1892
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_zero'>zero</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="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="Registry.html#zero_for-class_method" title="Mint::Registry.zero_for (method)">zero_for</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span></pre>
|
|
1376
1893
|
</td>
|
|
1377
1894
|
</tr>
|
|
1378
1895
|
</table>
|
|
@@ -1383,7 +1900,7 @@ or the code is not registered</p></div>
|
|
|
1383
1900
|
</div>
|
|
1384
1901
|
|
|
1385
1902
|
<div id="footer">
|
|
1386
|
-
Generated on
|
|
1903
|
+
Generated on Tue Jun 16 20:22:19 2026 by
|
|
1387
1904
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1388
1905
|
0.9.44 (ruby-4.0.5).
|
|
1389
1906
|
</div>
|