minting 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -1
- data/doc/Mint/Currency.html +285 -31
- data/doc/Mint/Money.html +79 -56
- data/doc/Mint/RangeStepPatch.html +1 -1
- data/doc/Mint/Registry.html +842 -0
- data/doc/Mint/UnknownCurrency.html +1 -1
- data/doc/Mint.html +345 -51
- data/doc/Minting.html +2 -2
- data/doc/_index.html +8 -8
- data/doc/agents/api_review-2026-06-15.md +342 -0
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +13 -2
- data/doc/index.html +13 -2
- data/doc/method_list.html +100 -36
- data/doc/top-level-namespace.html +1 -1
- data/lib/minting/currency/currency.rb +31 -0
- data/lib/minting/mint/locale_backend.rb +29 -0
- data/lib/minting/mint/mint.rb +23 -21
- data/lib/minting/mint/parser/parser.rb +3 -7
- 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 +18 -0
- data/lib/minting/mint.rb +13 -25
- data/lib/minting/money/constructors.rb +6 -11
- 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 -0
- data/lib/minting/version.rb +1 -1
- metadata +13 -8
- 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/{copilot-instructions.md → expired/copilot-instructions.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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ebe31c2ae1b9febafa3a6a4ccea1392cb089242746a933d530121b08f55cd4e
|
|
4
|
+
data.tar.gz: 80f1eb17f62b7a7924df8b2fedb79d864bcadd5ea5e8432e5149b14fb0d9af0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44147d3523485fc36491bb62f24df5f4040fe3ddda673201d5b6fc9a5e005bda94cd3300b4e84682f4378cb9eedb851ad16c247a2dfeb9de264fd24a6b1714ca
|
|
7
|
+
data.tar.gz: 5f41672831c8c722e47de8b8e94549bb633c48b677fc8e63eca9f10233062f32a0acd276b31271a4f0ac4417779b03db7f034a9b9afcfbd39c0cbadb16886dbf
|
data/README.md
CHANGED
|
@@ -172,6 +172,19 @@ Notes:
|
|
|
172
172
|
- Ambiguous symbols like `$` resolve by currency priority (currently USD).
|
|
173
173
|
- The parser scans all uppercase words for registered codes, so spurious non-currency words before the real code are correctly ignored: `Mint.parse("MAX 10.00 USD")` yields `[USD 10.00]`.
|
|
174
174
|
|
|
175
|
+
## Currency lookup
|
|
176
|
+
|
|
177
|
+
```ruby
|
|
178
|
+
# By ISO code (direct hash lookup, string only)
|
|
179
|
+
Mint.currency_for_code('USD') #=> #<Currency code="USD" ...>
|
|
180
|
+
|
|
181
|
+
# By display symbol (highest-priority currency for ambiguous symbols)
|
|
182
|
+
Mint.currency_for_symbol('$') #=> #<Currency code="USD" ...>
|
|
183
|
+
Mint.currency_for_symbol('R$') #=> #<Currency code="BRL" ...>
|
|
184
|
+
Mint.currency_for_symbol('€') #=> #<Currency code="EUR" ...>
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
|
|
175
188
|
## API notes
|
|
176
189
|
|
|
177
190
|
**Exact amounts** — Amounts are stored as `Rational` and rounded to the currency subunit.
|
|
@@ -182,7 +195,9 @@ Notes:
|
|
|
182
195
|
|
|
183
196
|
**Zero equality** — Any zero amount is considered equal across currencies and to numeric zero (`Mint.money(0, 'USD') == Mint.money(0, 'EUR')` is intentionally `true`). Non-zero amounts must match currency and value.
|
|
184
197
|
|
|
185
|
-
**
|
|
198
|
+
**Zero helper** — `Mint.zero('USD')` returns a frozen zero-Money, useful as a default value for discounts, totals, or counters.
|
|
199
|
+
|
|
200
|
+
**Registered currencies** — `Mint.register_currency(code:, subunit:, symbol:, priority:)` adds custom currencies. Only registered codes and symbols are recognized by the parser.
|
|
186
201
|
|
|
187
202
|
**Built-in currencies** — 150+ ISO-4217 world currencies ship in `lib/minting/data/currencies.yaml` and load when the registry is first accessed.
|
|
188
203
|
|
data/doc/Mint/Currency.html
CHANGED
|
@@ -324,6 +324,60 @@ 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="#resolve-class_method" title="resolve (class method)">.<strong>resolve</strong>(object) ⇒ 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>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>
|
|
352
|
+
|
|
353
|
+
</li>
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
<li class="public ">
|
|
357
|
+
<span class="summary_signature">
|
|
358
|
+
|
|
359
|
+
<a href="#resolve!-class_method" title="resolve! (class method)">.<strong>resolve!</strong>(object) ⇒ Currency </a>
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
</span>
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
<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>
|
|
374
|
+
|
|
375
|
+
</li>
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
</ul>
|
|
379
|
+
|
|
380
|
+
|
|
327
381
|
<h2>
|
|
328
382
|
Instance Method Summary
|
|
329
383
|
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
@@ -549,16 +603,16 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
549
603
|
<pre class="lines">
|
|
550
604
|
|
|
551
605
|
|
|
552
|
-
25
|
|
553
606
|
26
|
|
554
607
|
27
|
|
555
608
|
28
|
|
556
609
|
29
|
|
557
610
|
30
|
|
558
|
-
31
|
|
611
|
+
31
|
|
612
|
+
32</pre>
|
|
559
613
|
</td>
|
|
560
614
|
<td>
|
|
561
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
615
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 26</span>
|
|
562
616
|
|
|
563
617
|
<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
618
|
<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 +673,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
619
673
|
<pre class="lines">
|
|
620
674
|
|
|
621
675
|
|
|
622
|
-
17
|
|
623
676
|
18
|
|
624
|
-
19
|
|
677
|
+
19
|
|
678
|
+
20</pre>
|
|
625
679
|
</td>
|
|
626
680
|
<td>
|
|
627
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
681
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
628
682
|
|
|
629
683
|
<span class='kw'>def</span> <span class='id identifier rubyid_code'>code</span>
|
|
630
684
|
<span class='ivar'>@code</span>
|
|
@@ -676,12 +730,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
676
730
|
<pre class="lines">
|
|
677
731
|
|
|
678
732
|
|
|
679
|
-
17
|
|
680
733
|
18
|
|
681
|
-
19
|
|
734
|
+
19
|
|
735
|
+
20</pre>
|
|
682
736
|
</td>
|
|
683
737
|
<td>
|
|
684
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
738
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
685
739
|
|
|
686
740
|
<span class='kw'>def</span> <span class='id identifier rubyid_country'>country</span>
|
|
687
741
|
<span class='ivar'>@country</span>
|
|
@@ -733,12 +787,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
733
787
|
<pre class="lines">
|
|
734
788
|
|
|
735
789
|
|
|
736
|
-
17
|
|
737
790
|
18
|
|
738
|
-
19
|
|
791
|
+
19
|
|
792
|
+
20</pre>
|
|
739
793
|
</td>
|
|
740
794
|
<td>
|
|
741
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
795
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
742
796
|
|
|
743
797
|
<span class='kw'>def</span> <span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span>
|
|
744
798
|
<span class='ivar'>@fractional_multiplier</span>
|
|
@@ -790,12 +844,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
790
844
|
<pre class="lines">
|
|
791
845
|
|
|
792
846
|
|
|
793
|
-
17
|
|
794
847
|
18
|
|
795
|
-
19
|
|
848
|
+
19
|
|
849
|
+
20</pre>
|
|
796
850
|
</td>
|
|
797
851
|
<td>
|
|
798
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
852
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
799
853
|
|
|
800
854
|
<span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
|
|
801
855
|
<span class='ivar'>@name</span>
|
|
@@ -847,12 +901,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
847
901
|
<pre class="lines">
|
|
848
902
|
|
|
849
903
|
|
|
850
|
-
17
|
|
851
904
|
18
|
|
852
|
-
19
|
|
905
|
+
19
|
|
906
|
+
20</pre>
|
|
853
907
|
</td>
|
|
854
908
|
<td>
|
|
855
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
909
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
856
910
|
|
|
857
911
|
<span class='kw'>def</span> <span class='id identifier rubyid_priority'>priority</span>
|
|
858
912
|
<span class='ivar'>@priority</span>
|
|
@@ -904,12 +958,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
904
958
|
<pre class="lines">
|
|
905
959
|
|
|
906
960
|
|
|
907
|
-
17
|
|
908
961
|
18
|
|
909
|
-
19
|
|
962
|
+
19
|
|
963
|
+
20</pre>
|
|
910
964
|
</td>
|
|
911
965
|
<td>
|
|
912
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
966
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
913
967
|
|
|
914
968
|
<span class='kw'>def</span> <span class='id identifier rubyid_subunit'>subunit</span>
|
|
915
969
|
<span class='ivar'>@subunit</span>
|
|
@@ -961,12 +1015,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
961
1015
|
<pre class="lines">
|
|
962
1016
|
|
|
963
1017
|
|
|
964
|
-
17
|
|
965
1018
|
18
|
|
966
|
-
19
|
|
1019
|
+
19
|
|
1020
|
+
20</pre>
|
|
967
1021
|
</td>
|
|
968
1022
|
<td>
|
|
969
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1023
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
970
1024
|
|
|
971
1025
|
<span class='kw'>def</span> <span class='id identifier rubyid_symbol'>symbol</span>
|
|
972
1026
|
<span class='ivar'>@symbol</span>
|
|
@@ -979,6 +1033,206 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
979
1033
|
</div>
|
|
980
1034
|
|
|
981
1035
|
|
|
1036
|
+
<div id="class_method_details" class="method_details_list">
|
|
1037
|
+
<h2>Class Method Details</h2>
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
<div class="method_details first">
|
|
1041
|
+
<h3 class="signature first" id="resolve-class_method">
|
|
1042
|
+
|
|
1043
|
+
.<strong>resolve</strong>(object) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
</h3><div class="docstring">
|
|
1050
|
+
<div class="discussion">
|
|
1051
|
+
<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>
|
|
1052
|
+
<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>.
|
|
1053
|
+
Passing a <span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span> extracts its currency</p>
|
|
1054
|
+
|
|
1055
|
+
</div>
|
|
1056
|
+
</div>
|
|
1057
|
+
<div class="tags">
|
|
1058
|
+
<p class="tag_title">Parameters:</p>
|
|
1059
|
+
<ul class="param">
|
|
1060
|
+
|
|
1061
|
+
<li>
|
|
1062
|
+
|
|
1063
|
+
<span class='name'>object</span>
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
<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>
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
—
|
|
1071
|
+
<div class='inline'><p>a currency code, object, or <code>nil</code></p></div>
|
|
1072
|
+
|
|
1073
|
+
</li>
|
|
1074
|
+
|
|
1075
|
+
</ul>
|
|
1076
|
+
|
|
1077
|
+
<p class="tag_title">Returns:</p>
|
|
1078
|
+
<ul class="return">
|
|
1079
|
+
|
|
1080
|
+
<li>
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
—
|
|
1088
|
+
<div class='inline'><p>the resolved Currency, or <code>nil</code> if <code>object</code> is <code>nil</code>
|
|
1089
|
+
or the code is not registered</p></div>
|
|
1090
|
+
|
|
1091
|
+
</li>
|
|
1092
|
+
|
|
1093
|
+
</ul>
|
|
1094
|
+
<p class="tag_title">Raises:</p>
|
|
1095
|
+
<ul class="raise">
|
|
1096
|
+
|
|
1097
|
+
<li>
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
—
|
|
1105
|
+
<div class='inline'><p>if <code>object</code> is an unsupported type (e.g. <code>Integer</code>)</p></div>
|
|
1106
|
+
|
|
1107
|
+
</li>
|
|
1108
|
+
|
|
1109
|
+
</ul>
|
|
1110
|
+
|
|
1111
|
+
</div><table class="source_code">
|
|
1112
|
+
<tr>
|
|
1113
|
+
<td>
|
|
1114
|
+
<pre class="lines">
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
55
|
|
1118
|
+
56
|
|
1119
|
+
57
|
|
1120
|
+
58
|
|
1121
|
+
59
|
|
1122
|
+
60
|
|
1123
|
+
61
|
|
1124
|
+
62
|
|
1125
|
+
63</pre>
|
|
1126
|
+
</td>
|
|
1127
|
+
<td>
|
|
1128
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 55</span>
|
|
1129
|
+
|
|
1130
|
+
<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
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_object'>object</span>
|
|
1132
|
+
<span class='kw'>when</span> <span class='const'>NilClass</span> <span class='kw'>then</span> <span class='kw'>nil</span>
|
|
1133
|
+
<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
|
+
<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="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_currency_for_code'><span class='object_link'><a href="../Mint.html#currency_for_code-class_method" title="Mint.currency_for_code (method)">currency_for_code</a></span></span> <span class='id identifier rubyid_object'>object</span>
|
|
1136
|
+
<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
|
+
<span class='kw'>end</span>
|
|
1138
|
+
<span class='kw'>end</span></pre>
|
|
1139
|
+
</td>
|
|
1140
|
+
</tr>
|
|
1141
|
+
</table>
|
|
1142
|
+
</div>
|
|
1143
|
+
|
|
1144
|
+
<div class="method_details ">
|
|
1145
|
+
<h3 class="signature " id="resolve!-class_method">
|
|
1146
|
+
|
|
1147
|
+
.<strong>resolve!</strong>(object) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
</h3><div class="docstring">
|
|
1154
|
+
<div class="discussion">
|
|
1155
|
+
<p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Mint::Currency</a></span>, raising on failure.</p>
|
|
1156
|
+
<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>
|
|
1157
|
+
|
|
1158
|
+
</div>
|
|
1159
|
+
</div>
|
|
1160
|
+
<div class="tags">
|
|
1161
|
+
<p class="tag_title">Parameters:</p>
|
|
1162
|
+
<ul class="param">
|
|
1163
|
+
|
|
1164
|
+
<li>
|
|
1165
|
+
|
|
1166
|
+
<span class='name'>object</span>
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
<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>
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
—
|
|
1174
|
+
<div class='inline'><p>a currency code, object, or <code>nil</code></p></div>
|
|
1175
|
+
|
|
1176
|
+
</li>
|
|
1177
|
+
|
|
1178
|
+
</ul>
|
|
1179
|
+
|
|
1180
|
+
<p class="tag_title">Returns:</p>
|
|
1181
|
+
<ul class="return">
|
|
1182
|
+
|
|
1183
|
+
<li>
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
—
|
|
1191
|
+
<div class='inline'><p>the resolved Currency</p></div>
|
|
1192
|
+
|
|
1193
|
+
</li>
|
|
1194
|
+
|
|
1195
|
+
</ul>
|
|
1196
|
+
<p class="tag_title">Raises:</p>
|
|
1197
|
+
<ul class="raise">
|
|
1198
|
+
|
|
1199
|
+
<li>
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
—
|
|
1207
|
+
<div class='inline'><p>if <code>object</code> cannot be resolved into a registered currency</p></div>
|
|
1208
|
+
|
|
1209
|
+
</li>
|
|
1210
|
+
|
|
1211
|
+
</ul>
|
|
1212
|
+
|
|
1213
|
+
</div><table class="source_code">
|
|
1214
|
+
<tr>
|
|
1215
|
+
<td>
|
|
1216
|
+
<pre class="lines">
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
72
|
|
1220
|
+
73
|
|
1221
|
+
74</pre>
|
|
1222
|
+
</td>
|
|
1223
|
+
<td>
|
|
1224
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 72</span>
|
|
1225
|
+
|
|
1226
|
+
<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
|
+
<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>
|
|
1228
|
+
<span class='kw'>end</span></pre>
|
|
1229
|
+
</td>
|
|
1230
|
+
</tr>
|
|
1231
|
+
</table>
|
|
1232
|
+
</div>
|
|
1233
|
+
|
|
1234
|
+
</div>
|
|
1235
|
+
|
|
982
1236
|
<div id="instance_method_details" class="method_details_list">
|
|
983
1237
|
<h2>Instance Method Details</h2>
|
|
984
1238
|
|
|
@@ -1023,10 +1277,10 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1023
1277
|
<pre class="lines">
|
|
1024
1278
|
|
|
1025
1279
|
|
|
1026
|
-
|
|
1280
|
+
35</pre>
|
|
1027
1281
|
</td>
|
|
1028
1282
|
<td>
|
|
1029
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1283
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 35</span>
|
|
1030
1284
|
|
|
1031
1285
|
<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>
|
|
1032
1286
|
</td>
|
|
@@ -1074,10 +1328,10 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1074
1328
|
<pre class="lines">
|
|
1075
1329
|
|
|
1076
1330
|
|
|
1077
|
-
|
|
1331
|
+
38</pre>
|
|
1078
1332
|
</td>
|
|
1079
1333
|
<td>
|
|
1080
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1334
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 38</span>
|
|
1081
1335
|
|
|
1082
1336
|
<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>
|
|
1083
1337
|
</td>
|
|
@@ -1113,10 +1367,10 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1113
1367
|
<pre class="lines">
|
|
1114
1368
|
|
|
1115
1369
|
|
|
1116
|
-
|
|
1370
|
+
43</pre>
|
|
1117
1371
|
</td>
|
|
1118
1372
|
<td>
|
|
1119
|
-
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line
|
|
1373
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 43</span>
|
|
1120
1374
|
|
|
1121
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='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_subunit'>subunit</span><span class='rparen'>)</span></pre>
|
|
1122
1376
|
</td>
|
|
@@ -1129,7 +1383,7 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
1129
1383
|
</div>
|
|
1130
1384
|
|
|
1131
1385
|
<div id="footer">
|
|
1132
|
-
Generated on
|
|
1386
|
+
Generated on Mon Jun 15 19:57:57 2026 by
|
|
1133
1387
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1134
1388
|
0.9.44 (ruby-4.0.5).
|
|
1135
1389
|
</div>
|