minting 1.7.2 → 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 +35 -3
- data/doc/Mint/Currency.html +826 -55
- data/doc/Mint/Money.html +715 -218
- data/doc/Mint/RangeStepPatch.html +1 -1
- data/doc/Mint/Registry.html +859 -0
- data/doc/Mint/Rounding.html +495 -0
- data/doc/Mint/UnknownCurrency.html +1 -1
- data/doc/Mint.html +307 -225
- data/doc/Minting.html +2 -2
- data/doc/_index.html +15 -8
- data/doc/agents/api_review-2026-06-15.md +329 -0
- data/doc/agents/copilot-instructions.md +0 -5
- data/doc/agents/expired/copilot-instructions.md +75 -0
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +25 -4
- data/doc/index.html +25 -4
- data/doc/method_list.html +177 -25
- data/doc/top-level-namespace.html +1 -1
- data/lib/minting/currency/currency.rb +71 -1
- data/lib/minting/mint/dsl/range.rb +1 -0
- data/lib/minting/mint/locale_backend.rb +29 -0
- data/lib/minting/mint/mint.rb +13 -38
- data/lib/minting/mint/parser/parser.rb +50 -19
- data/lib/minting/mint/parser/separators.rb +10 -8
- data/lib/minting/mint/registry/registration.rb +33 -0
- data/lib/minting/mint/registry/registry.rb +38 -0
- data/lib/minting/mint/registry/symbols.rb +49 -0
- data/lib/minting/mint/registry/zeros.rb +20 -0
- data/lib/minting/mint/rounding.rb +51 -0
- data/lib/minting/mint.rb +12 -23
- 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 +63 -20
- data/lib/minting/money/format/formatting.rb +16 -0
- data/lib/minting/money/format/to_s.rb +13 -4
- data/lib/minting/money/money.rb +12 -6
- data/lib/minting/version.rb +1 -1
- metadata +15 -7
- data/lib/minting/currency/currency_registry.rb +0 -67
- data/lib/minting/currency/world_currencies.rb +0 -16
- /data/doc/agents/{AGENTS.md → expired/AGENTS.md} +0 -0
- /data/doc/agents/{gemini_gem_evaluation.md → expired/gemini_gem_evaluation.md} +0 -0
- /data/doc/agents/{recommendations.md → expired/recommendations.md} +0 -0
- /data/doc/agents/{rubocop-issues.md → expired/rubocop-issues.md} +0 -0
data/doc/Mint/Currency.html
CHANGED
|
@@ -324,6 +324,148 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
|
|
327
|
+
<h2>
|
|
328
|
+
Class Method Summary
|
|
329
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
330
|
+
</h2>
|
|
331
|
+
|
|
332
|
+
<ul class="summary">
|
|
333
|
+
|
|
334
|
+
<li class="public ">
|
|
335
|
+
<span class="summary_signature">
|
|
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
|
+
|
|
403
|
+
<a href="#resolve-class_method" title="resolve (class method)">.<strong>resolve</strong>(object) ⇒ Currency<sup>?</sup> </a>
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
</span>
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
<span class="summary_desc"><div class='inline'><p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span>, returning <code>nil</code> when it can't.</p></div></span>
|
|
418
|
+
|
|
419
|
+
</li>
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
<li class="public ">
|
|
423
|
+
<span class="summary_signature">
|
|
424
|
+
|
|
425
|
+
<a href="#resolve!-class_method" title="resolve! (class method)">.<strong>resolve!</strong>(object) ⇒ Currency </a>
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
</span>
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
<span class="summary_desc"><div class='inline'><p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span>, raising on failure.</p></div></span>
|
|
440
|
+
|
|
441
|
+
</li>
|
|
442
|
+
|
|
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
|
+
|
|
466
|
+
</ul>
|
|
467
|
+
|
|
468
|
+
|
|
327
469
|
<h2>
|
|
328
470
|
Instance Method Summary
|
|
329
471
|
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
@@ -421,6 +563,28 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
421
563
|
</li>
|
|
422
564
|
|
|
423
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
|
+
|
|
424
588
|
</ul>
|
|
425
589
|
|
|
426
590
|
|
|
@@ -549,16 +713,16 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
549
713
|
<pre class="lines">
|
|
550
714
|
|
|
551
715
|
|
|
552
|
-
25
|
|
553
716
|
26
|
|
554
717
|
27
|
|
555
718
|
28
|
|
556
719
|
29
|
|
557
720
|
30
|
|
558
|
-
31
|
|
721
|
+
31
|
|
722
|
+
32</pre>
|
|
559
723
|
</td>
|
|
560
724
|
<td>
|
|
561
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
725
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 26</span>
|
|
562
726
|
|
|
563
727
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>symbol:</span><span class='comma'>,</span> <span class='label'>subunit:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>country:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>name:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
564
728
|
<span class='id identifier rubyid_subunit'>subunit</span> <span class='op'>=</span> <span class='id identifier rubyid_subunit'>subunit</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
|
|
@@ -619,12 +783,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
619
783
|
<pre class="lines">
|
|
620
784
|
|
|
621
785
|
|
|
622
|
-
17
|
|
623
786
|
18
|
|
624
|
-
19
|
|
787
|
+
19
|
|
788
|
+
20</pre>
|
|
625
789
|
</td>
|
|
626
790
|
<td>
|
|
627
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
791
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
628
792
|
|
|
629
793
|
<span class='kw'>def</span> <span class='id identifier rubyid_code'>code</span>
|
|
630
794
|
<span class='ivar'>@code</span>
|
|
@@ -676,12 +840,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
676
840
|
<pre class="lines">
|
|
677
841
|
|
|
678
842
|
|
|
679
|
-
17
|
|
680
843
|
18
|
|
681
|
-
19
|
|
844
|
+
19
|
|
845
|
+
20</pre>
|
|
682
846
|
</td>
|
|
683
847
|
<td>
|
|
684
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
848
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
685
849
|
|
|
686
850
|
<span class='kw'>def</span> <span class='id identifier rubyid_country'>country</span>
|
|
687
851
|
<span class='ivar'>@country</span>
|
|
@@ -733,12 +897,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
733
897
|
<pre class="lines">
|
|
734
898
|
|
|
735
899
|
|
|
736
|
-
17
|
|
737
900
|
18
|
|
738
|
-
19
|
|
901
|
+
19
|
|
902
|
+
20</pre>
|
|
739
903
|
</td>
|
|
740
904
|
<td>
|
|
741
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
905
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
742
906
|
|
|
743
907
|
<span class='kw'>def</span> <span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span>
|
|
744
908
|
<span class='ivar'>@fractional_multiplier</span>
|
|
@@ -790,12 +954,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
790
954
|
<pre class="lines">
|
|
791
955
|
|
|
792
956
|
|
|
793
|
-
17
|
|
794
957
|
18
|
|
795
|
-
19
|
|
958
|
+
19
|
|
959
|
+
20</pre>
|
|
796
960
|
</td>
|
|
797
961
|
<td>
|
|
798
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
962
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
799
963
|
|
|
800
964
|
<span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
|
|
801
965
|
<span class='ivar'>@name</span>
|
|
@@ -847,12 +1011,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
847
1011
|
<pre class="lines">
|
|
848
1012
|
|
|
849
1013
|
|
|
850
|
-
17
|
|
851
1014
|
18
|
|
852
|
-
19
|
|
1015
|
+
19
|
|
1016
|
+
20</pre>
|
|
853
1017
|
</td>
|
|
854
1018
|
<td>
|
|
855
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1019
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
856
1020
|
|
|
857
1021
|
<span class='kw'>def</span> <span class='id identifier rubyid_priority'>priority</span>
|
|
858
1022
|
<span class='ivar'>@priority</span>
|
|
@@ -904,12 +1068,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
904
1068
|
<pre class="lines">
|
|
905
1069
|
|
|
906
1070
|
|
|
907
|
-
17
|
|
908
1071
|
18
|
|
909
|
-
19
|
|
1072
|
+
19
|
|
1073
|
+
20</pre>
|
|
910
1074
|
</td>
|
|
911
1075
|
<td>
|
|
912
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1076
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
913
1077
|
|
|
914
1078
|
<span class='kw'>def</span> <span class='id identifier rubyid_subunit'>subunit</span>
|
|
915
1079
|
<span class='ivar'>@subunit</span>
|
|
@@ -961,12 +1125,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
961
1125
|
<pre class="lines">
|
|
962
1126
|
|
|
963
1127
|
|
|
964
|
-
17
|
|
965
1128
|
18
|
|
966
|
-
19
|
|
1129
|
+
19
|
|
1130
|
+
20</pre>
|
|
967
1131
|
</td>
|
|
968
1132
|
<td>
|
|
969
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1133
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
970
1134
|
|
|
971
1135
|
<span class='kw'>def</span> <span class='id identifier rubyid_symbol'>symbol</span>
|
|
972
1136
|
<span class='ivar'>@symbol</span>
|
|
@@ -979,14 +1143,14 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
979
1143
|
</div>
|
|
980
1144
|
|
|
981
1145
|
|
|
982
|
-
<div id="
|
|
983
|
-
<h2>
|
|
1146
|
+
<div id="class_method_details" class="method_details_list">
|
|
1147
|
+
<h2>Class Method Details</h2>
|
|
984
1148
|
|
|
985
1149
|
|
|
986
1150
|
<div class="method_details first">
|
|
987
|
-
<h3 class="signature first" id="
|
|
1151
|
+
<h3 class="signature first" id="for_code-class_method">
|
|
988
1152
|
|
|
989
|
-
|
|
1153
|
+
.<strong>for_code</strong>(code) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
990
1154
|
|
|
991
1155
|
|
|
992
1156
|
|
|
@@ -994,24 +1158,42 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
994
1158
|
|
|
995
1159
|
</h3><div class="docstring">
|
|
996
1160
|
<div class="discussion">
|
|
997
|
-
<p>
|
|
1161
|
+
<p>Looks up a registered currency by its alpha code.</p>
|
|
998
1162
|
|
|
999
1163
|
</div>
|
|
1000
1164
|
</div>
|
|
1001
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>
|
|
1002
1182
|
|
|
1183
|
+
</ul>
|
|
1184
|
+
|
|
1003
1185
|
<p class="tag_title">Returns:</p>
|
|
1004
1186
|
<ul class="return">
|
|
1005
1187
|
|
|
1006
1188
|
<li>
|
|
1007
1189
|
|
|
1008
1190
|
|
|
1009
|
-
<span class='type'>(<tt>
|
|
1191
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1010
1192
|
|
|
1011
1193
|
|
|
1012
1194
|
|
|
1013
1195
|
—
|
|
1014
|
-
<div class='inline'><p>
|
|
1196
|
+
<div class='inline'><p>the registered Currency, or <code>nil</code> if not found</p></div>
|
|
1015
1197
|
|
|
1016
1198
|
</li>
|
|
1017
1199
|
|
|
@@ -1023,21 +1205,25 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1023
1205
|
<pre class="lines">
|
|
1024
1206
|
|
|
1025
1207
|
|
|
1026
|
-
|
|
1208
|
+
95
|
|
1209
|
+
96
|
|
1210
|
+
97</pre>
|
|
1027
1211
|
</td>
|
|
1028
1212
|
<td>
|
|
1029
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1213
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 95</span>
|
|
1030
1214
|
|
|
1031
|
-
<span class='kw'>def</span> <span class='
|
|
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>
|
|
1032
1218
|
</td>
|
|
1033
1219
|
</tr>
|
|
1034
1220
|
</table>
|
|
1035
1221
|
</div>
|
|
1036
1222
|
|
|
1037
1223
|
<div class="method_details ">
|
|
1038
|
-
<h3 class="signature " id="
|
|
1224
|
+
<h3 class="signature " id="for_symbol-class_method">
|
|
1039
1225
|
|
|
1040
|
-
|
|
1226
|
+
.<strong>for_symbol</strong>(symbol) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
1041
1227
|
|
|
1042
1228
|
|
|
1043
1229
|
|
|
@@ -1045,24 +1231,42 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1045
1231
|
|
|
1046
1232
|
</h3><div class="docstring">
|
|
1047
1233
|
<div class="discussion">
|
|
1048
|
-
<p>
|
|
1234
|
+
<p>Looks up a currency by its display symbol.</p>
|
|
1049
1235
|
|
|
1050
1236
|
</div>
|
|
1051
1237
|
</div>
|
|
1052
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>
|
|
1053
1255
|
|
|
1256
|
+
</ul>
|
|
1257
|
+
|
|
1054
1258
|
<p class="tag_title">Returns:</p>
|
|
1055
1259
|
<ul class="return">
|
|
1056
1260
|
|
|
1057
1261
|
<li>
|
|
1058
1262
|
|
|
1059
1263
|
|
|
1060
|
-
<span class='type'>(<tt>
|
|
1264
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1061
1265
|
|
|
1062
1266
|
|
|
1063
1267
|
|
|
1064
1268
|
—
|
|
1065
|
-
<div class='inline'><p>
|
|
1269
|
+
<div class='inline'><p>the highest-priority currency for the symbol</p></div>
|
|
1066
1270
|
|
|
1067
1271
|
</li>
|
|
1068
1272
|
|
|
@@ -1074,21 +1278,25 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1074
1278
|
<pre class="lines">
|
|
1075
1279
|
|
|
1076
1280
|
|
|
1077
|
-
|
|
1281
|
+
103
|
|
1282
|
+
104
|
|
1283
|
+
105</pre>
|
|
1078
1284
|
</td>
|
|
1079
1285
|
<td>
|
|
1080
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1286
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 103</span>
|
|
1081
1287
|
|
|
1082
|
-
<span class='kw'>def</span> <span class='
|
|
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>
|
|
1083
1291
|
</td>
|
|
1084
1292
|
</tr>
|
|
1085
1293
|
</table>
|
|
1086
1294
|
</div>
|
|
1087
1295
|
|
|
1088
1296
|
<div class="method_details ">
|
|
1089
|
-
<h3 class="signature " id="
|
|
1297
|
+
<h3 class="signature " id="register-class_method">
|
|
1090
1298
|
|
|
1091
|
-
|
|
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>
|
|
1092
1300
|
|
|
1093
1301
|
|
|
1094
1302
|
|
|
@@ -1096,29 +1304,592 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1096
1304
|
|
|
1097
1305
|
</h3><div class="docstring">
|
|
1098
1306
|
<div class="discussion">
|
|
1099
|
-
<p>
|
|
1100
|
-
<ol>
|
|
1101
|
-
<li>Converts to Rational</li>
|
|
1102
|
-
<li>Rounds to respect currency subunit</li>
|
|
1103
|
-
</ol>
|
|
1307
|
+
<p>Registers a new currency, raising a KeyError if already registered.</p>
|
|
1104
1308
|
|
|
1105
1309
|
</div>
|
|
1106
1310
|
</div>
|
|
1107
1311
|
<div class="tags">
|
|
1312
|
+
<p class="tag_title">Parameters:</p>
|
|
1313
|
+
<ul class="param">
|
|
1108
1314
|
|
|
1109
|
-
|
|
1110
|
-
|
|
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">
|
|
1447
|
+
|
|
1448
|
+
.<strong>resolve</strong>(object) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
</h3><div class="docstring">
|
|
1455
|
+
<div class="discussion">
|
|
1456
|
+
<p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Mint::Currency</a></span>, returning <code>nil</code> when it can't.</p>
|
|
1457
|
+
<p>Accepts <code>nil</code>, <code>String</code>, <span class='object_link'><a href="" title="Mint::Currency (class)">Mint::Currency</a></span>, or <span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span>.
|
|
1458
|
+
Passing a <span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span> extracts its currency</p>
|
|
1459
|
+
|
|
1460
|
+
</div>
|
|
1461
|
+
</div>
|
|
1462
|
+
<div class="tags">
|
|
1463
|
+
<p class="tag_title">Parameters:</p>
|
|
1464
|
+
<ul class="param">
|
|
1465
|
+
|
|
1466
|
+
<li>
|
|
1467
|
+
|
|
1468
|
+
<span class='name'>object</span>
|
|
1469
|
+
|
|
1470
|
+
|
|
1471
|
+
<span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>, <tt>nil</tt>)</span>
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
—
|
|
1476
|
+
<div class='inline'><p>a currency code, object, or <code>nil</code></p></div>
|
|
1477
|
+
|
|
1478
|
+
</li>
|
|
1479
|
+
|
|
1480
|
+
</ul>
|
|
1481
|
+
|
|
1482
|
+
<p class="tag_title">Returns:</p>
|
|
1483
|
+
<ul class="return">
|
|
1484
|
+
|
|
1485
|
+
<li>
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1489
|
+
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
—
|
|
1493
|
+
<div class='inline'><p>the resolved Currency, or <code>nil</code> if <code>object</code> is <code>nil</code>
|
|
1494
|
+
or the code is not registered</p></div>
|
|
1495
|
+
|
|
1496
|
+
</li>
|
|
1497
|
+
|
|
1498
|
+
</ul>
|
|
1499
|
+
<p class="tag_title">Raises:</p>
|
|
1500
|
+
<ul class="raise">
|
|
1501
|
+
|
|
1502
|
+
<li>
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
—
|
|
1510
|
+
<div class='inline'><p>if <code>object</code> is an unsupported type (e.g. <code>Integer</code>)</p></div>
|
|
1511
|
+
|
|
1512
|
+
</li>
|
|
1513
|
+
|
|
1514
|
+
</ul>
|
|
1515
|
+
|
|
1516
|
+
</div><table class="source_code">
|
|
1517
|
+
<tr>
|
|
1518
|
+
<td>
|
|
1519
|
+
<pre class="lines">
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
70
|
|
1523
|
+
71
|
|
1524
|
+
72
|
|
1525
|
+
73
|
|
1526
|
+
74
|
|
1527
|
+
75
|
|
1528
|
+
76
|
|
1529
|
+
77
|
|
1530
|
+
78</pre>
|
|
1531
|
+
</td>
|
|
1532
|
+
<td>
|
|
1533
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 70</span>
|
|
1534
|
+
|
|
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>
|
|
1536
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_object'>object</span>
|
|
1537
|
+
<span class='kw'>when</span> <span class='const'>NilClass</span> <span class='kw'>then</span> <span class='kw'>nil</span>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
1542
|
+
<span class='kw'>end</span>
|
|
1543
|
+
<span class='kw'>end</span></pre>
|
|
1544
|
+
</td>
|
|
1545
|
+
</tr>
|
|
1546
|
+
</table>
|
|
1547
|
+
</div>
|
|
1548
|
+
|
|
1549
|
+
<div class="method_details ">
|
|
1550
|
+
<h3 class="signature " id="resolve!-class_method">
|
|
1551
|
+
|
|
1552
|
+
.<strong>resolve!</strong>(object) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>
|
|
1553
|
+
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
</h3><div class="docstring">
|
|
1559
|
+
<div class="discussion">
|
|
1560
|
+
<p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Mint::Currency</a></span>, raising on failure.</p>
|
|
1561
|
+
<p>Like <span class='object_link'><a href="#resolve-class_method" title="Mint::Currency.resolve (method)">resolve</a></span> but raises when the result would be <code>nil</code>.</p>
|
|
1562
|
+
|
|
1563
|
+
</div>
|
|
1564
|
+
</div>
|
|
1565
|
+
<div class="tags">
|
|
1566
|
+
<p class="tag_title">Parameters:</p>
|
|
1567
|
+
<ul class="param">
|
|
1568
|
+
|
|
1569
|
+
<li>
|
|
1570
|
+
|
|
1571
|
+
<span class='name'>object</span>
|
|
1572
|
+
|
|
1573
|
+
|
|
1574
|
+
<span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>, <tt>nil</tt>)</span>
|
|
1575
|
+
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
—
|
|
1579
|
+
<div class='inline'><p>a currency code, object, or <code>nil</code></p></div>
|
|
1580
|
+
|
|
1581
|
+
</li>
|
|
1582
|
+
|
|
1583
|
+
</ul>
|
|
1584
|
+
|
|
1585
|
+
<p class="tag_title">Returns:</p>
|
|
1586
|
+
<ul class="return">
|
|
1587
|
+
|
|
1588
|
+
<li>
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
|
|
1595
|
+
—
|
|
1596
|
+
<div class='inline'><p>the resolved Currency</p></div>
|
|
1597
|
+
|
|
1598
|
+
</li>
|
|
1599
|
+
|
|
1600
|
+
</ul>
|
|
1601
|
+
<p class="tag_title">Raises:</p>
|
|
1602
|
+
<ul class="raise">
|
|
1603
|
+
|
|
1604
|
+
<li>
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1608
|
+
|
|
1609
|
+
|
|
1610
|
+
|
|
1611
|
+
—
|
|
1612
|
+
<div class='inline'><p>if <code>object</code> cannot be resolved into a registered currency</p></div>
|
|
1613
|
+
|
|
1614
|
+
</li>
|
|
1615
|
+
|
|
1616
|
+
</ul>
|
|
1617
|
+
|
|
1618
|
+
</div><table class="source_code">
|
|
1619
|
+
<tr>
|
|
1620
|
+
<td>
|
|
1621
|
+
<pre class="lines">
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
87
|
|
1625
|
+
88
|
|
1626
|
+
89</pre>
|
|
1627
|
+
</td>
|
|
1628
|
+
<td>
|
|
1629
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 87</span>
|
|
1630
|
+
|
|
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>
|
|
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>
|
|
1633
|
+
<span class='kw'>end</span></pre>
|
|
1634
|
+
</td>
|
|
1635
|
+
</tr>
|
|
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>
|
|
1723
|
+
</div>
|
|
1724
|
+
|
|
1725
|
+
</div>
|
|
1726
|
+
|
|
1727
|
+
<div id="instance_method_details" class="method_details_list">
|
|
1728
|
+
<h2>Instance Method Details</h2>
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
<div class="method_details first">
|
|
1732
|
+
<h3 class="signature first" id="inspect-instance_method">
|
|
1733
|
+
|
|
1734
|
+
#<strong>inspect</strong> ⇒ <tt>String</tt>
|
|
1735
|
+
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
</h3><div class="docstring">
|
|
1741
|
+
<div class="discussion">
|
|
1742
|
+
<p>Returns debug representation.</p>
|
|
1743
|
+
|
|
1744
|
+
</div>
|
|
1745
|
+
</div>
|
|
1746
|
+
<div class="tags">
|
|
1747
|
+
|
|
1748
|
+
<p class="tag_title">Returns:</p>
|
|
1749
|
+
<ul class="return">
|
|
1750
|
+
|
|
1751
|
+
<li>
|
|
1752
|
+
|
|
1753
|
+
|
|
1754
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1755
|
+
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
—
|
|
1759
|
+
<div class='inline'><p>debug representation</p></div>
|
|
1760
|
+
|
|
1761
|
+
</li>
|
|
1762
|
+
|
|
1763
|
+
</ul>
|
|
1764
|
+
|
|
1765
|
+
</div><table class="source_code">
|
|
1766
|
+
<tr>
|
|
1767
|
+
<td>
|
|
1768
|
+
<pre class="lines">
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
35</pre>
|
|
1772
|
+
</td>
|
|
1773
|
+
<td>
|
|
1774
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 35</span>
|
|
1775
|
+
|
|
1776
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_inspect'>inspect</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'><Currency:(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_code'>code</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_symbol'>symbol</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_subunit'>subunit</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>)></span><span class='tstring_end'>"</span></span></pre>
|
|
1777
|
+
</td>
|
|
1778
|
+
</tr>
|
|
1779
|
+
</table>
|
|
1780
|
+
</div>
|
|
1781
|
+
|
|
1782
|
+
<div class="method_details ">
|
|
1783
|
+
<h3 class="signature " id="minimum_amount-instance_method">
|
|
1784
|
+
|
|
1785
|
+
#<strong>minimum_amount</strong> ⇒ <tt>Rational</tt>
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
</h3><div class="docstring">
|
|
1792
|
+
<div class="discussion">
|
|
1793
|
+
<p>Returns smallest representable amount (1/fractional_multiplier).</p>
|
|
1794
|
+
|
|
1795
|
+
</div>
|
|
1796
|
+
</div>
|
|
1797
|
+
<div class="tags">
|
|
1798
|
+
|
|
1799
|
+
<p class="tag_title">Returns:</p>
|
|
1800
|
+
<ul class="return">
|
|
1801
|
+
|
|
1802
|
+
<li>
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
<span class='type'>(<tt>Rational</tt>)</span>
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
|
|
1809
|
+
—
|
|
1810
|
+
<div class='inline'><p>smallest representable amount (1/fractional_multiplier)</p></div>
|
|
1811
|
+
|
|
1812
|
+
</li>
|
|
1813
|
+
|
|
1814
|
+
</ul>
|
|
1815
|
+
|
|
1816
|
+
</div><table class="source_code">
|
|
1817
|
+
<tr>
|
|
1818
|
+
<td>
|
|
1819
|
+
<pre class="lines">
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
38</pre>
|
|
1823
|
+
</td>
|
|
1824
|
+
<td>
|
|
1825
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 38</span>
|
|
1826
|
+
|
|
1827
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_minimum_amount'>minimum_amount</span> <span class='op'>=</span> <span class='const'>Rational</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span><span class='rparen'>)</span></pre>
|
|
1828
|
+
</td>
|
|
1829
|
+
</tr>
|
|
1830
|
+
</table>
|
|
1831
|
+
</div>
|
|
1832
|
+
|
|
1833
|
+
<div class="method_details ">
|
|
1834
|
+
<h3 class="signature " id="normalize_amount-instance_method">
|
|
1835
|
+
|
|
1836
|
+
#<strong>normalize_amount</strong>(amount) ⇒ <tt>Object</tt>
|
|
1837
|
+
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
|
|
1841
|
+
|
|
1842
|
+
</h3><div class="docstring">
|
|
1843
|
+
<div class="discussion">
|
|
1844
|
+
<p>Normalizes numeric amounts for this currency</p>
|
|
1845
|
+
<ol>
|
|
1846
|
+
<li>Converts to Rational</li>
|
|
1847
|
+
<li>Rounds to respect currency subunit</li>
|
|
1848
|
+
</ol>
|
|
1849
|
+
|
|
1850
|
+
</div>
|
|
1851
|
+
</div>
|
|
1852
|
+
<div class="tags">
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
</div><table class="source_code">
|
|
1856
|
+
<tr>
|
|
1857
|
+
<td>
|
|
1858
|
+
<pre class="lines">
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
43</pre>
|
|
1862
|
+
</td>
|
|
1863
|
+
<td>
|
|
1864
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 43</span>
|
|
1865
|
+
|
|
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">
|
|
1111
1882
|
<tr>
|
|
1112
1883
|
<td>
|
|
1113
1884
|
<pre class="lines">
|
|
1114
1885
|
|
|
1115
1886
|
|
|
1116
|
-
|
|
1887
|
+
45</pre>
|
|
1117
1888
|
</td>
|
|
1118
1889
|
<td>
|
|
1119
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1890
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 45</span>
|
|
1120
1891
|
|
|
1121
|
-
<span class='kw'>def</span> <span class='id identifier
|
|
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>
|
|
1122
1893
|
</td>
|
|
1123
1894
|
</tr>
|
|
1124
1895
|
</table>
|
|
@@ -1129,7 +1900,7 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1129
1900
|
</div>
|
|
1130
1901
|
|
|
1131
1902
|
<div id="footer">
|
|
1132
|
-
Generated on
|
|
1903
|
+
Generated on Tue Jun 16 20:22:19 2026 by
|
|
1133
1904
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1134
1905
|
0.9.44 (ruby-4.0.5).
|
|
1135
1906
|
</div>
|