minting 1.9.6 → 1.9.7
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 +30 -25
- data/Rakefile +16 -20
- data/bin/bench_check +2 -2
- data/doc/Mint/Currency.html +183 -94
- data/doc/Mint/Money.html +866 -334
- data/doc/Mint/RangeStepPatch.html +1 -1
- data/doc/Mint/Registry.html +10 -10
- data/doc/Mint/Rounding.html +2 -2
- data/doc/Mint/UnknownCurrency.html +6 -4
- data/doc/Mint.html +33 -106
- data/doc/Minting.html +2 -2
- data/doc/Numeric.html +479 -0
- data/doc/String.html +241 -0
- data/doc/_index.html +27 -1
- data/doc/agents/copilot-instructions.md +3 -3
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +47 -33
- data/doc/index.html +47 -33
- data/doc/method_list.html +125 -53
- data/doc/top-level-namespace.html +5 -21
- data/lib/minting/currency/currency.rb +6 -3
- data/lib/minting/data/world-currencies.yaml +75 -23
- data/lib/minting/mint/i18n.rb +1 -1
- data/lib/minting/mint/rounding.rb +1 -0
- data/lib/minting/money/conversion.rb +1 -0
- data/lib/minting/money/format/formatting.rb +88 -55
- data/lib/minting/money/format/to_s.rb +20 -3
- data/lib/minting/money/money.rb +0 -4
- data/lib/minting/version.rb +1 -1
- metadata +3 -2
- data/doc/Mint/CurrencyRegistry.html +0 -511
data/doc/Mint/Money.html
CHANGED
|
@@ -140,7 +140,17 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
140
140
|
|
|
141
141
|
</div>
|
|
142
142
|
</dt>
|
|
143
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<symbol>s%<amount>f</span><span class='tstring_end'>'</span></span></pre></dd>
|
|
143
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<symbol>s%<amount>f</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
144
|
+
|
|
145
|
+
<dt id="PRESETS-constant" class="">PRESETS =
|
|
146
|
+
|
|
147
|
+
</dt>
|
|
148
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
|
149
|
+
<span class='label'>amount:</span> <span class='lbrace'>{</span> <span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>f</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
150
|
+
<span class='label'>accounting:</span> <span class='lbrace'>{</span> <span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>negative:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>(%<symbol>s%<amount>f)</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
151
|
+
<span class='label'>european:</span> <span class='lbrace'>{</span> <span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>f %<symbol>s</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>decimal:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>thousand:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
152
|
+
<span class='label'>currency:</span> <span class='lbrace'>{</span> <span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<currency>s %<amount>f</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span>
|
|
153
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
144
154
|
|
|
145
155
|
</dl>
|
|
146
156
|
|
|
@@ -221,7 +231,51 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
221
231
|
<li class="public ">
|
|
222
232
|
<span class="summary_signature">
|
|
223
233
|
|
|
224
|
-
<a href="#
|
|
234
|
+
<a href="#compile_formatter-class_method" title="compile_formatter (class method)">.<strong>compile_formatter</strong>(format_hash, currency, decimal, thousand) ⇒ Object </a>
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
</span>
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
<span class="summary_desc"><div class='inline'><p>Builds and returns a lambda that formats amounts for a fixed [format_config, currency, decimal, thousand] combination.</p></div></span>
|
|
249
|
+
|
|
250
|
+
</li>
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
<li class="public ">
|
|
254
|
+
<span class="summary_signature">
|
|
255
|
+
|
|
256
|
+
<a href="#compile_templates-class_method" title="compile_templates (class method)">.<strong>compile_templates</strong>(format_hash, subunit) ⇒ Object </a>
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
</span>
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
<span class="summary_desc"><div class='inline'><p>Build each sign template with subunit precision baked in, returning a frozen Hash of templates keyed by sign (:positive, :negative, :zero).</p></div></span>
|
|
271
|
+
|
|
272
|
+
</li>
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
<li class="public ">
|
|
276
|
+
<span class="summary_signature">
|
|
277
|
+
|
|
278
|
+
<a href="#compiled_formatters-class_method" title="compiled_formatters (class method)">.<strong>compiled_formatters</strong> ⇒ Object </a>
|
|
225
279
|
|
|
226
280
|
|
|
227
281
|
|
|
@@ -235,7 +289,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
235
289
|
|
|
236
290
|
|
|
237
291
|
|
|
238
|
-
<span class="summary_desc"><div class='inline'
|
|
292
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
239
293
|
|
|
240
294
|
</li>
|
|
241
295
|
|
|
@@ -528,7 +582,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
528
582
|
|
|
529
583
|
|
|
530
584
|
|
|
531
|
-
|
|
585
|
+
<span class="private note title">private</span>
|
|
532
586
|
|
|
533
587
|
|
|
534
588
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
@@ -550,7 +604,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
550
604
|
|
|
551
605
|
|
|
552
606
|
|
|
553
|
-
|
|
607
|
+
<span class="private note title">private</span>
|
|
554
608
|
|
|
555
609
|
|
|
556
610
|
<span class="summary_desc"><div class='inline'><p>True if both are zero, or both have same amount and same currency.</p></div></span>
|
|
@@ -605,6 +659,28 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
605
659
|
<li class="public ">
|
|
606
660
|
<span class="summary_signature">
|
|
607
661
|
|
|
662
|
+
<a href="#amount_to_s-instance_method" title="#amount_to_s (instance method)">#<strong>amount_to_s</strong>(thousand: ',') ⇒ Object </a>
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
</span>
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
677
|
+
|
|
678
|
+
</li>
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
<li class="public ">
|
|
682
|
+
<span class="summary_signature">
|
|
683
|
+
|
|
608
684
|
<a href="#clamp-instance_method" title="#clamp (instance method)">#<strong>clamp</strong>(min_or_range, max = nil) ⇒ Money </a>
|
|
609
685
|
|
|
610
686
|
|
|
@@ -704,7 +780,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
704
780
|
|
|
705
781
|
|
|
706
782
|
|
|
707
|
-
|
|
783
|
+
<span class="private note title">private</span>
|
|
708
784
|
|
|
709
785
|
|
|
710
786
|
<span class="summary_desc"><div class='inline'><p>Strict equality — both amount and currency must match exactly.</p></div></span>
|
|
@@ -715,6 +791,30 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
715
791
|
<li class="public ">
|
|
716
792
|
<span class="summary_signature">
|
|
717
793
|
|
|
794
|
+
<a href="#format-instance_method" title="#format (instance method)">#<strong>format</strong>(preset = nil, format: nil, decimal: nil, thousand: nil, width: nil) ⇒ String </a>
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
(also: #to_fs)
|
|
799
|
+
|
|
800
|
+
</span>
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
<span class="summary_desc"><div class='inline'><p>Formats money as a string with customizable format, thousand delimiter, and decimal.</p></div></span>
|
|
811
|
+
|
|
812
|
+
</li>
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
<li class="public ">
|
|
816
|
+
<span class="summary_signature">
|
|
817
|
+
|
|
718
818
|
<a href="#fractional-instance_method" title="#fractional (instance method)">#<strong>fractional</strong> ⇒ Object </a>
|
|
719
819
|
|
|
720
820
|
|
|
@@ -836,7 +936,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
836
936
|
|
|
837
937
|
|
|
838
938
|
|
|
839
|
-
|
|
939
|
+
<span class="private note title">private</span>
|
|
840
940
|
|
|
841
941
|
|
|
842
942
|
<span class="summary_desc"><div class='inline'><p>Self if amount is non-zero, nil otherwise.</p></div></span>
|
|
@@ -880,7 +980,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
880
980
|
|
|
881
981
|
|
|
882
982
|
|
|
883
|
-
|
|
983
|
+
<span class="private note title">private</span>
|
|
884
984
|
|
|
885
985
|
|
|
886
986
|
<span class="summary_desc"><div class='inline'><p>Helper method to verify if another Money has the identical currency.</p></div></span>
|
|
@@ -968,7 +1068,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
968
1068
|
|
|
969
1069
|
|
|
970
1070
|
|
|
971
|
-
|
|
1071
|
+
<span class="private note title">private</span>
|
|
972
1072
|
|
|
973
1073
|
|
|
974
1074
|
<span class="summary_desc"><div class='inline'><p>Converts the monetary amount to a BigDecimal object.</p></div></span>
|
|
@@ -990,7 +1090,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
990
1090
|
|
|
991
1091
|
|
|
992
1092
|
|
|
993
|
-
|
|
1093
|
+
<span class="private note title">private</span>
|
|
994
1094
|
|
|
995
1095
|
|
|
996
1096
|
<span class="summary_desc"><div class='inline'><p>Converts the monetary amount to a standard float.</p></div></span>
|
|
@@ -1012,7 +1112,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1012
1112
|
|
|
1013
1113
|
|
|
1014
1114
|
|
|
1015
|
-
|
|
1115
|
+
<span class="private note title">private</span>
|
|
1016
1116
|
|
|
1017
1117
|
|
|
1018
1118
|
<span class="summary_desc"><div class='inline'><p>Returns a Hash representation of the money instance.</p></div></span>
|
|
@@ -1034,7 +1134,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1034
1134
|
|
|
1035
1135
|
|
|
1036
1136
|
|
|
1037
|
-
|
|
1137
|
+
<span class="private note title">private</span>
|
|
1038
1138
|
|
|
1039
1139
|
|
|
1040
1140
|
<span class="summary_desc"><div class='inline'><p>Renders a safe HTML5 <code><data></code> element containing the formatted currency.</p></div></span>
|
|
@@ -1056,7 +1156,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1056
1156
|
|
|
1057
1157
|
|
|
1058
1158
|
|
|
1059
|
-
|
|
1159
|
+
<span class="private note title">private</span>
|
|
1060
1160
|
|
|
1061
1161
|
|
|
1062
1162
|
<span class="summary_desc"><div class='inline'><p>Truncates and converts the monetary amount to an Integer.</p></div></span>
|
|
@@ -1078,7 +1178,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1078
1178
|
|
|
1079
1179
|
|
|
1080
1180
|
|
|
1081
|
-
|
|
1181
|
+
<span class="private note title">private</span>
|
|
1082
1182
|
|
|
1083
1183
|
|
|
1084
1184
|
<span class="summary_desc"><div class='inline'><p>Serializes the money instance to a standard JSON object containing the amount and currency.</p></div></span>
|
|
@@ -1100,7 +1200,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1100
1200
|
|
|
1101
1201
|
|
|
1102
1202
|
|
|
1103
|
-
|
|
1203
|
+
<span class="private note title">private</span>
|
|
1104
1204
|
|
|
1105
1205
|
|
|
1106
1206
|
<span class="summary_desc"><div class='inline'><p>Returns the exact internal Rational representation of the monetary amount.</p></div></span>
|
|
@@ -1111,7 +1211,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1111
1211
|
<li class="public ">
|
|
1112
1212
|
<span class="summary_signature">
|
|
1113
1213
|
|
|
1114
|
-
<a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong>
|
|
1214
|
+
<a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong> ⇒ Object </a>
|
|
1115
1215
|
|
|
1116
1216
|
|
|
1117
1217
|
|
|
@@ -1125,7 +1225,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1125
1225
|
|
|
1126
1226
|
|
|
1127
1227
|
|
|
1128
|
-
<span class="summary_desc"><div class='inline'
|
|
1228
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
1129
1229
|
|
|
1130
1230
|
</li>
|
|
1131
1231
|
|
|
@@ -1144,7 +1244,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1144
1244
|
|
|
1145
1245
|
|
|
1146
1246
|
|
|
1147
|
-
|
|
1247
|
+
<span class="private note title">private</span>
|
|
1148
1248
|
|
|
1149
1249
|
|
|
1150
1250
|
<span class="summary_desc"><div class='inline'><p>True if amount is zero.</p></div></span>
|
|
@@ -1187,12 +1287,12 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1187
1287
|
<pre class="lines">
|
|
1188
1288
|
|
|
1189
1289
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1290
|
+
20
|
|
1291
|
+
21
|
|
1292
|
+
22</pre>
|
|
1193
1293
|
</td>
|
|
1194
1294
|
<td>
|
|
1195
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
1295
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 20</span>
|
|
1196
1296
|
|
|
1197
1297
|
<span class='kw'>def</span> <span class='id identifier rubyid_amount'>amount</span>
|
|
1198
1298
|
<span class='ivar'>@amount</span>
|
|
@@ -1228,12 +1328,12 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1228
1328
|
<pre class="lines">
|
|
1229
1329
|
|
|
1230
1330
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1331
|
+
20
|
|
1332
|
+
21
|
|
1333
|
+
22</pre>
|
|
1234
1334
|
</td>
|
|
1235
1335
|
<td>
|
|
1236
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
1336
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 20</span>
|
|
1237
1337
|
|
|
1238
1338
|
<span class='kw'>def</span> <span class='id identifier rubyid_currency'>currency</span>
|
|
1239
1339
|
<span class='ivar'>@currency</span>
|
|
@@ -1251,9 +1351,9 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1251
1351
|
|
|
1252
1352
|
|
|
1253
1353
|
<div class="method_details first">
|
|
1254
|
-
<h3 class="signature first" id="
|
|
1354
|
+
<h3 class="signature first" id="compile_formatter-class_method">
|
|
1255
1355
|
|
|
1256
|
-
.<strong>
|
|
1356
|
+
.<strong>compile_formatter</strong>(format_hash, currency, decimal, thousand) ⇒ <tt>Object</tt>
|
|
1257
1357
|
|
|
1258
1358
|
|
|
1259
1359
|
|
|
@@ -1261,8 +1361,9 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1261
1361
|
|
|
1262
1362
|
</h3><div class="docstring">
|
|
1263
1363
|
<div class="discussion">
|
|
1264
|
-
<p>
|
|
1265
|
-
|
|
1364
|
+
<p>Builds and returns a lambda that formats amounts for a fixed
|
|
1365
|
+
[format_config, currency, decimal, thousand] combination.
|
|
1366
|
+
The lambda is cached by <span class='object_link'><a href="#compiled_formatters-class_method" title="Mint::Money.compiled_formatters (method)">compiled_formatters</a></span>.</p>
|
|
1266
1367
|
|
|
1267
1368
|
</div>
|
|
1268
1369
|
</div>
|
|
@@ -1275,17 +1376,214 @@ TODO: deprecate in a future major release</p>
|
|
|
1275
1376
|
<pre class="lines">
|
|
1276
1377
|
|
|
1277
1378
|
|
|
1379
|
+
39
|
|
1380
|
+
40
|
|
1381
|
+
41
|
|
1382
|
+
42
|
|
1383
|
+
43
|
|
1384
|
+
44
|
|
1385
|
+
45
|
|
1386
|
+
46
|
|
1387
|
+
47
|
|
1388
|
+
48
|
|
1389
|
+
49
|
|
1390
|
+
50
|
|
1391
|
+
51
|
|
1392
|
+
52
|
|
1393
|
+
53
|
|
1394
|
+
54
|
|
1395
|
+
55
|
|
1396
|
+
56
|
|
1397
|
+
57
|
|
1398
|
+
58
|
|
1399
|
+
59
|
|
1400
|
+
60
|
|
1401
|
+
61
|
|
1402
|
+
62
|
|
1403
|
+
63
|
|
1404
|
+
64
|
|
1405
|
+
65
|
|
1406
|
+
66
|
|
1407
|
+
67
|
|
1408
|
+
68
|
|
1278
1409
|
69
|
|
1279
1410
|
70
|
|
1280
1411
|
71
|
|
1281
|
-
72
|
|
1412
|
+
72
|
|
1413
|
+
73
|
|
1414
|
+
74
|
|
1415
|
+
75
|
|
1416
|
+
76
|
|
1417
|
+
77
|
|
1418
|
+
78
|
|
1419
|
+
79
|
|
1420
|
+
80
|
|
1421
|
+
81
|
|
1422
|
+
82
|
|
1423
|
+
83
|
|
1424
|
+
84
|
|
1425
|
+
85
|
|
1426
|
+
86
|
|
1427
|
+
87
|
|
1428
|
+
88</pre>
|
|
1429
|
+
</td>
|
|
1430
|
+
<td>
|
|
1431
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/format/formatting.rb', line 39</span>
|
|
1432
|
+
|
|
1433
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compile_formatter'>compile_formatter</span><span class='lparen'>(</span><span class='id identifier rubyid_format_hash'>format_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='comma'>,</span> <span class='id identifier rubyid_decimal'>decimal</span><span class='comma'>,</span> <span class='id identifier rubyid_thousand'>thousand</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
1434
|
+
</span> <span class='id identifier rubyid_subunit'>subunit</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_subunit'>subunit</span>
|
|
1435
|
+
<span class='id identifier rubyid_has_decimal_substitution'>has_decimal_substitution</span> <span class='op'>=</span> <span class='id identifier rubyid_decimal'>decimal</span> <span class='op'>!=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span>
|
|
1436
|
+
<span class='id identifier rubyid_escaped_decimal'>escaped_decimal</span> <span class='op'>=</span> <span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_escape'>escape</span><span class='lparen'>(</span><span class='id identifier rubyid_decimal'>decimal</span><span class='rparen'>)</span>
|
|
1437
|
+
<span class='id identifier rubyid_has_thousand_separator'>has_thousand_separator</span> <span class='op'>=</span> <span class='id identifier rubyid_thousand'>thousand</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_thousand'>thousand</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
|
1438
|
+
|
|
1439
|
+
<span class='id identifier rubyid_templates'>templates</span> <span class='op'>=</span> <span class='id identifier rubyid_compile_templates'>compile_templates</span><span class='lparen'>(</span><span class='id identifier rubyid_format_hash'>format_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_subunit'>subunit</span><span class='rparen'>)</span>
|
|
1440
|
+
<span class='id identifier rubyid_positive_template'>positive_template</span><span class='comma'>,</span> <span class='id identifier rubyid_negative_template'>negative_template</span><span class='comma'>,</span> <span class='id identifier rubyid_zero_template'>zero_template</span> <span class='op'>=</span> <span class='id identifier rubyid_templates'>templates</span>
|
|
1441
|
+
|
|
1442
|
+
<span class='comment'># Detect whether templates use %<fractional> and/or %<d-symbol>
|
|
1443
|
+
</span> <span class='id identifier rubyid_all_templates'>all_templates</span> <span class='op'>=</span> <span class='id identifier rubyid_templates'>templates</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span>
|
|
1444
|
+
<span class='id identifier rubyid_needs_fractional'>needs_fractional</span> <span class='op'>=</span> <span class='id identifier rubyid_all_templates'>all_templates</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<fractional></span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
1445
|
+
<span class='id identifier rubyid_needs_integral'>needs_integral</span> <span class='op'>=</span> <span class='id identifier rubyid_all_templates'>all_templates</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount></span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_all_templates'>all_templates</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<integral></span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
1446
|
+
<span class='id identifier rubyid_multiplier'>multiplier</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span>
|
|
1447
|
+
<span class='id identifier rubyid_symbol'>symbol</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_symbol'>symbol</span>
|
|
1448
|
+
|
|
1449
|
+
<span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
|
1450
|
+
<span class='label'>currency:</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span><span class='comma'>,</span>
|
|
1451
|
+
<span class='label'>dsymbol:</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_disambiguate_symbol'>disambiguate_symbol</span> <span class='op'>||</span> <span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span>
|
|
1452
|
+
<span class='label'>symbol:</span> <span class='id identifier rubyid_symbol'>symbol</span>
|
|
1453
|
+
<span class='rbrace'>}</span>
|
|
1454
|
+
|
|
1455
|
+
<span class='id identifier rubyid_lambda'>lambda</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_amount'>amount</span><span class='op'>|</span>
|
|
1456
|
+
<span class='id identifier rubyid_format_template'>format_template</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id identifier rubyid_negative_template'>negative_template</span> <span class='op'>&&</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'><</span> <span class='int'>0</span>
|
|
1457
|
+
<span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='op'>-</span><span class='id identifier rubyid_amount'>amount</span>
|
|
1458
|
+
<span class='id identifier rubyid_negative_template'>negative_template</span>
|
|
1459
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_zero_template'>zero_template</span> <span class='op'>&&</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>==</span> <span class='int'>0</span>
|
|
1460
|
+
<span class='id identifier rubyid_zero_template'>zero_template</span>
|
|
1461
|
+
<span class='kw'>else</span>
|
|
1462
|
+
<span class='id identifier rubyid_positive_template'>positive_template</span>
|
|
1463
|
+
<span class='kw'>end</span>
|
|
1464
|
+
|
|
1465
|
+
<span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='symbol'>:amount</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span>
|
|
1466
|
+
<span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='symbol'>:integral</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
|
|
1467
|
+
<span class='id identifier rubyid_args'>args</span><span class='lbracket'>[</span><span class='symbol'>:fractional</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_abs'>abs</span> <span class='op'>%</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='op'>*</span> <span class='id identifier rubyid_multiplier'>multiplier</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='kw'>if</span> <span class='id identifier rubyid_needs_fractional'>needs_fractional</span>
|
|
1468
|
+
|
|
1469
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='id identifier rubyid_format_template'>format_template</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
1470
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(?<=\d)\.(?=\d)</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='id identifier rubyid_decimal'>decimal</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_has_decimal_substitution'>has_decimal_substitution</span>
|
|
1471
|
+
|
|
1472
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_needs_integral'>needs_integral</span> <span class='op'>&&</span> <span class='id identifier rubyid_has_thousand_separator'>has_thousand_separator</span> <span class='op'>&&</span> <span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span> <span class='op'>>=</span> <span class='int'>1000</span> <span class='op'>||</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'><=</span> <span class='op'>-</span><span class='int'>1000</span><span class='rparen'>)</span>
|
|
1473
|
+
<span class='comment'># Split on the decimal separator between digits only — symbols may contain '.' (e.g. د.إ).
|
|
1474
|
+
</span> <span class='id identifier rubyid_parts'>parts</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(?<=\d)</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_escaped_decimal'>escaped_decimal</span><span class='embexpr_end'>}</span><span class='tstring_content'>(?=\d)</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='int'>2</span><span class='rparen'>)</span>
|
|
1475
|
+
<span class='comment'># Insert the thousands delimiter before each run of 3 digits from the right.
|
|
1476
|
+
</span> <span class='id identifier rubyid_parts'>parts</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\d)(?=(?:\d{3})+(?:[^\d]|$))</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_last_match'>last_match</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_thousand'>thousand</span> <span class='rbrace'>}</span>
|
|
1477
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_parts'>parts</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_decimal'>decimal</span><span class='rparen'>)</span>
|
|
1478
|
+
<span class='kw'>end</span>
|
|
1479
|
+
|
|
1480
|
+
<span class='id identifier rubyid_result'>result</span>
|
|
1481
|
+
<span class='kw'>end</span>
|
|
1482
|
+
<span class='kw'>end</span></pre>
|
|
1483
|
+
</td>
|
|
1484
|
+
</tr>
|
|
1485
|
+
</table>
|
|
1486
|
+
</div>
|
|
1487
|
+
|
|
1488
|
+
<div class="method_details ">
|
|
1489
|
+
<h3 class="signature " id="compile_templates-class_method">
|
|
1490
|
+
|
|
1491
|
+
.<strong>compile_templates</strong>(format_hash, subunit) ⇒ <tt>Object</tt>
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
</h3><div class="docstring">
|
|
1498
|
+
<div class="discussion">
|
|
1499
|
+
<p>Build each sign template with subunit precision baked in, returning a
|
|
1500
|
+
frozen Hash of templates keyed by sign (:positive, :negative, :zero).
|
|
1501
|
+
Keeps %<symbol>s and %<currency>s as format args so width/padding specifiers work.</p>
|
|
1502
|
+
|
|
1503
|
+
</div>
|
|
1504
|
+
</div>
|
|
1505
|
+
<div class="tags">
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
</div><table class="source_code">
|
|
1509
|
+
<tr>
|
|
1510
|
+
<td>
|
|
1511
|
+
<pre class="lines">
|
|
1512
|
+
|
|
1513
|
+
|
|
1514
|
+
14
|
|
1515
|
+
15
|
|
1516
|
+
16
|
|
1517
|
+
17
|
|
1518
|
+
18
|
|
1519
|
+
19
|
|
1520
|
+
20
|
|
1521
|
+
21
|
|
1522
|
+
22
|
|
1523
|
+
23
|
|
1524
|
+
24
|
|
1525
|
+
25
|
|
1526
|
+
26
|
|
1527
|
+
27
|
|
1528
|
+
28
|
|
1529
|
+
29
|
|
1530
|
+
30
|
|
1531
|
+
31
|
|
1532
|
+
32
|
|
1533
|
+
33</pre>
|
|
1534
|
+
</td>
|
|
1535
|
+
<td>
|
|
1536
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/format/formatting.rb', line 14</span>
|
|
1537
|
+
|
|
1538
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compile_templates'>compile_templates</span><span class='lparen'>(</span><span class='id identifier rubyid_format_hash'>format_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_subunit'>subunit</span><span class='rparen'>)</span>
|
|
1539
|
+
<span class='lbracket'>[</span>
|
|
1540
|
+
<span class='id identifier rubyid_format_hash'>format_hash</span><span class='lbracket'>[</span><span class='symbol'>:positive</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="#DEFAULT_FORMAT-constant" title="Mint::Money::DEFAULT_FORMAT (constant)">DEFAULT_FORMAT</a></span></span><span class='comma'>,</span>
|
|
1541
|
+
<span class='id identifier rubyid_format_hash'>format_hash</span><span class='lbracket'>[</span><span class='symbol'>:negative</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
|
1542
|
+
<span class='id identifier rubyid_format_hash'>format_hash</span><span class='lbracket'>[</span><span class='symbol'>:zero</span><span class='rbracket'>]</span>
|
|
1543
|
+
<span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_sign_format'>sign_format</span><span class='op'>|</span>
|
|
1544
|
+
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_sign_format'>sign_format</span>
|
|
1545
|
+
|
|
1546
|
+
<span class='comment'># Injects the currency's subunit precision into %<amount>f specifiers
|
|
1547
|
+
</span> <span class='comment'># (e.g. '%<amount>f' → '%<amount>.2f' for USD), preserving any
|
|
1548
|
+
</span> <span class='comment'># existing width/alignment specifier (e.g. '%<amount>+10f' stays).
|
|
1549
|
+
</span> <span class='id identifier rubyid_sign_format'>sign_format</span> <span class='op'>=</span> <span class='id identifier rubyid_sign_format'>sign_format</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>%<amount>(\s*\+?\d*)f</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%<amount>\\1.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_subunit'>subunit</span><span class='embexpr_end'>}</span><span class='tstring_content'>f</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
|
1550
|
+
|
|
1551
|
+
<span class='comment'># For zero-subunit currencies (JPY, KRW, etc.), strip %<fractional>d
|
|
1552
|
+
</span> <span class='comment'># specifiers entirely since there is no fractional part to display.
|
|
1553
|
+
</span> <span class='id identifier rubyid_sign_format'>sign_format</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>%<fractional>[^%]*?d</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_subunit'>subunit</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</span>
|
|
1554
|
+
|
|
1555
|
+
<span class='id identifier rubyid_sign_format'>sign_format</span>
|
|
1556
|
+
<span class='kw'>end</span>
|
|
1557
|
+
<span class='kw'>end</span></pre>
|
|
1558
|
+
</td>
|
|
1559
|
+
</tr>
|
|
1560
|
+
</table>
|
|
1561
|
+
</div>
|
|
1562
|
+
|
|
1563
|
+
<div class="method_details ">
|
|
1564
|
+
<h3 class="signature " id="compiled_formatters-class_method">
|
|
1565
|
+
|
|
1566
|
+
.<strong>compiled_formatters</strong> ⇒ <tt>Object</tt>
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
</h3><table class="source_code">
|
|
1573
|
+
<tr>
|
|
1574
|
+
<td>
|
|
1575
|
+
<pre class="lines">
|
|
1576
|
+
|
|
1577
|
+
|
|
1578
|
+
6
|
|
1579
|
+
7
|
|
1580
|
+
8</pre>
|
|
1282
1581
|
</td>
|
|
1283
1582
|
<td>
|
|
1284
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/
|
|
1583
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/format/formatting.rb', line 6</span>
|
|
1285
1584
|
|
|
1286
|
-
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier
|
|
1287
|
-
<span class='
|
|
1288
|
-
<span class='id identifier rubyid_from'>from</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
1585
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_compiled_formatters'>compiled_formatters</span>
|
|
1586
|
+
<span class='ivar'>@compiled_formatters</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
1289
1587
|
<span class='kw'>end</span></pre>
|
|
1290
1588
|
</td>
|
|
1291
1589
|
</tr>
|
|
@@ -1324,7 +1622,7 @@ TODO: deprecate in a future major release</p>
|
|
|
1324
1622
|
<span class='name'>amount</span>
|
|
1325
1623
|
|
|
1326
1624
|
|
|
1327
|
-
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
1625
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
1328
1626
|
|
|
1329
1627
|
|
|
1330
1628
|
|
|
@@ -1338,7 +1636,7 @@ TODO: deprecate in a future major release</p>
|
|
|
1338
1636
|
<span class='name'>currency</span>
|
|
1339
1637
|
|
|
1340
1638
|
|
|
1341
|
-
<span class='type'>(<tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>String</tt>)</span>
|
|
1639
|
+
<span class='type'>(<tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
1342
1640
|
|
|
1343
1641
|
|
|
1344
1642
|
|
|
@@ -1376,7 +1674,19 @@ TODO: deprecate in a future major release</p>
|
|
|
1376
1674
|
|
|
1377
1675
|
|
|
1378
1676
|
—
|
|
1379
|
-
<div class='inline'><p>If amount is not numeric
|
|
1677
|
+
<div class='inline'><p>If amount is not numeric</p></div>
|
|
1678
|
+
|
|
1679
|
+
</li>
|
|
1680
|
+
|
|
1681
|
+
<li>
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
<span class='type'>(<tt><span class='object_link'><a href="UnknownCurrency.html" title="Mint::UnknownCurrency (class)">Mint::UnknownCurrency</a></span></tt>)</span>
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
—
|
|
1689
|
+
<div class='inline'><p>If currency cannot be resolved</p></div>
|
|
1380
1690
|
|
|
1381
1691
|
</li>
|
|
1382
1692
|
|
|
@@ -1388,20 +1698,20 @@ TODO: deprecate in a future major release</p>
|
|
|
1388
1698
|
<pre class="lines">
|
|
1389
1699
|
|
|
1390
1700
|
|
|
1391
|
-
13
|
|
1392
1701
|
14
|
|
1393
1702
|
15
|
|
1394
1703
|
16
|
|
1395
1704
|
17
|
|
1396
1705
|
18
|
|
1397
1706
|
19
|
|
1398
|
-
20
|
|
1707
|
+
20
|
|
1708
|
+
21</pre>
|
|
1399
1709
|
</td>
|
|
1400
1710
|
<td>
|
|
1401
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
1711
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 14</span>
|
|
1402
1712
|
|
|
1403
1713
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from'>from</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
1404
|
-
<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'>amount must be Numeric</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Numeric</span><span class='rparen'>)</span>
|
|
1714
|
+
<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'>amount must be Numeric</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></span><span class='rparen'>)</span>
|
|
1405
1715
|
|
|
1406
1716
|
<span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve!'><span class='object_link'><a href="Currency.html#resolve!-class_method" title="Mint::Currency.resolve! (method)">resolve!</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
1407
1717
|
<span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_normalize_amount'>normalize_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span>
|
|
@@ -1475,7 +1785,7 @@ smallest unit (e.g. cents). Must be an Integer to preserve exactness.</p></div>
|
|
|
1475
1785
|
<span class='name'>currency</span>
|
|
1476
1786
|
|
|
1477
1787
|
|
|
1478
|
-
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1788
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1479
1789
|
|
|
1480
1790
|
|
|
1481
1791
|
|
|
@@ -1513,8 +1823,19 @@ smallest unit (e.g. cents). Must be an Integer to preserve exactness.</p></div>
|
|
|
1513
1823
|
|
|
1514
1824
|
|
|
1515
1825
|
—
|
|
1516
|
-
<div class='inline'><p>if <code>subunits</code> is not an Integer
|
|
1517
|
-
|
|
1826
|
+
<div class='inline'><p>if <code>subunits</code> is not an Integer</p></div>
|
|
1827
|
+
|
|
1828
|
+
</li>
|
|
1829
|
+
|
|
1830
|
+
<li>
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
<span class='type'>(<tt><span class='object_link'><a href="UnknownCurrency.html" title="Mint::UnknownCurrency (class)">Mint::UnknownCurrency</a></span></tt>)</span>
|
|
1834
|
+
|
|
1835
|
+
|
|
1836
|
+
|
|
1837
|
+
—
|
|
1838
|
+
<div class='inline'><p>if <code>currency</code> is not registered</p></div>
|
|
1518
1839
|
|
|
1519
1840
|
</li>
|
|
1520
1841
|
|
|
@@ -1526,16 +1847,16 @@ is not registered</p></div>
|
|
|
1526
1847
|
<pre class="lines">
|
|
1527
1848
|
|
|
1528
1849
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1850
|
+
86
|
|
1851
|
+
87
|
|
1852
|
+
88
|
|
1853
|
+
89
|
|
1854
|
+
90
|
|
1855
|
+
91
|
|
1856
|
+
92</pre>
|
|
1536
1857
|
</td>
|
|
1537
1858
|
<td>
|
|
1538
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
1859
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 86</span>
|
|
1539
1860
|
|
|
1540
1861
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_subunits'>from_subunits</span><span class='lparen'>(</span><span class='id identifier rubyid_subunits'>subunits</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
1541
1862
|
<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'>subunits must be an Integer</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_subunits'>subunits</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Integer</span><span class='rparen'>)</span>
|
|
@@ -1581,7 +1902,7 @@ is not registered</p></div>
|
|
|
1581
1902
|
<span class='name'>amount</span>
|
|
1582
1903
|
|
|
1583
1904
|
|
|
1584
|
-
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
1905
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
1585
1906
|
|
|
1586
1907
|
|
|
1587
1908
|
|
|
@@ -1631,10 +1952,10 @@ is not registered</p></div>
|
|
|
1631
1952
|
<pre class="lines">
|
|
1632
1953
|
|
|
1633
1954
|
|
|
1634
|
-
|
|
1955
|
+
30</pre>
|
|
1635
1956
|
</td>
|
|
1636
1957
|
<td>
|
|
1637
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
1958
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 30</span>
|
|
1638
1959
|
|
|
1639
1960
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_no_currency'>no_currency</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_from'>from</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>XXX</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></pre>
|
|
1640
1961
|
</td>
|
|
@@ -1684,7 +2005,7 @@ is not registered</p></div>
|
|
|
1684
2005
|
<span class='name'>input</span>
|
|
1685
2006
|
|
|
1686
2007
|
|
|
1687
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
2008
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
1688
2009
|
|
|
1689
2010
|
|
|
1690
2011
|
|
|
@@ -1698,7 +2019,7 @@ is not registered</p></div>
|
|
|
1698
2019
|
<span class='name'>currency</span>
|
|
1699
2020
|
|
|
1700
2021
|
|
|
1701
|
-
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
2022
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1702
2023
|
|
|
1703
2024
|
|
|
1704
2025
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
@@ -1731,10 +2052,10 @@ is not registered</p></div>
|
|
|
1731
2052
|
<pre class="lines">
|
|
1732
2053
|
|
|
1733
2054
|
|
|
1734
|
-
|
|
2055
|
+
47</pre>
|
|
1735
2056
|
</td>
|
|
1736
2057
|
<td>
|
|
1737
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
2058
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 47</span>
|
|
1738
2059
|
|
|
1739
2060
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_parse'><span class='object_link'><a href="../Mint.html#parse-instance_method" title="Mint#parse (method)">parse</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span></pre>
|
|
1740
2061
|
</td>
|
|
@@ -1775,7 +2096,7 @@ is not registered</p></div>
|
|
|
1775
2096
|
<span class='name'>input</span>
|
|
1776
2097
|
|
|
1777
2098
|
|
|
1778
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
2099
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
1779
2100
|
|
|
1780
2101
|
|
|
1781
2102
|
|
|
@@ -1789,7 +2110,7 @@ is not registered</p></div>
|
|
|
1789
2110
|
<span class='name'>currency</span>
|
|
1790
2111
|
|
|
1791
2112
|
|
|
1792
|
-
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
2113
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1793
2114
|
|
|
1794
2115
|
|
|
1795
2116
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
@@ -1838,10 +2159,10 @@ is not registered</p></div>
|
|
|
1838
2159
|
<pre class="lines">
|
|
1839
2160
|
|
|
1840
2161
|
|
|
1841
|
-
|
|
2162
|
+
59</pre>
|
|
1842
2163
|
</td>
|
|
1843
2164
|
<td>
|
|
1844
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
2165
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 59</span>
|
|
1845
2166
|
|
|
1846
2167
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse!'>parse!</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_parse!'><span class='object_link'><a href="../Mint.html#parse!-instance_method" title="Mint#parse! (method)">parse!</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span></pre>
|
|
1847
2168
|
</td>
|
|
@@ -1873,7 +2194,7 @@ is not registered</p></div>
|
|
|
1873
2194
|
<span class='name'>currency</span>
|
|
1874
2195
|
|
|
1875
2196
|
|
|
1876
|
-
<span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
2197
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>, <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1877
2198
|
|
|
1878
2199
|
|
|
1879
2200
|
|
|
@@ -1906,7 +2227,7 @@ is not registered</p></div>
|
|
|
1906
2227
|
<li>
|
|
1907
2228
|
|
|
1908
2229
|
|
|
1909
|
-
<span class='type'>(<tt>
|
|
2230
|
+
<span class='type'>(<tt><span class='object_link'><a href="UnknownCurrency.html" title="Mint::UnknownCurrency (class)">Mint::UnknownCurrency</a></span></tt>)</span>
|
|
1910
2231
|
|
|
1911
2232
|
|
|
1912
2233
|
|
|
@@ -1923,10 +2244,10 @@ is not registered</p></div>
|
|
|
1923
2244
|
<pre class="lines">
|
|
1924
2245
|
|
|
1925
2246
|
|
|
1926
|
-
|
|
2247
|
+
66</pre>
|
|
1927
2248
|
</td>
|
|
1928
2249
|
<td>
|
|
1929
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
2250
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 66</span>
|
|
1930
2251
|
|
|
1931
2252
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_zero'>zero</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve!'><span class='object_link'><a href="Currency.html#resolve!-class_method" title="Mint::Currency.resolve! (method)">resolve!</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_zero'><span class='object_link'><a href="Currency.html#zero-class_method" title="Mint::Currency.zero (method)">zero</a></span></span></pre>
|
|
1932
2253
|
</td>
|
|
@@ -1964,7 +2285,7 @@ is not registered</p></div>
|
|
|
1964
2285
|
<span class='name'>multiplicand</span>
|
|
1965
2286
|
|
|
1966
2287
|
|
|
1967
|
-
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
2288
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
1968
2289
|
|
|
1969
2290
|
|
|
1970
2291
|
|
|
@@ -2024,7 +2345,7 @@ is not registered</p></div>
|
|
|
2024
2345
|
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 42</span>
|
|
2025
2346
|
|
|
2026
2347
|
<span class='kw'>def</span> <span class='op'>*</span><span class='lparen'>(</span><span class='id identifier rubyid_multiplicand'>multiplicand</span><span class='rparen'>)</span>
|
|
2027
|
-
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'> can't be multiplied by </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_multiplicand'>multiplicand</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_multiplicand'>multiplicand</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Numeric</span><span class='rparen'>)</span>
|
|
2348
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'> can't be multiplied by </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_multiplicand'>multiplicand</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_multiplicand'>multiplicand</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></span><span class='rparen'>)</span>
|
|
2028
2349
|
|
|
2029
2350
|
<span class='id identifier rubyid_copy_with'>copy_with</span><span class='lparen'>(</span><span class='label'>amount:</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>*</span> <span class='id identifier rubyid_multiplicand'>multiplicand</span><span class='rparen'>)</span>
|
|
2030
2351
|
<span class='kw'>end</span></pre>
|
|
@@ -2057,7 +2378,7 @@ is not registered</p></div>
|
|
|
2057
2378
|
<span class='name'>exponent</span>
|
|
2058
2379
|
|
|
2059
2380
|
|
|
2060
|
-
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
2381
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
2061
2382
|
|
|
2062
2383
|
|
|
2063
2384
|
|
|
@@ -2114,7 +2435,7 @@ is not registered</p></div>
|
|
|
2114
2435
|
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 67</span>
|
|
2115
2436
|
|
|
2116
2437
|
<span class='kw'>def</span> <span class='op'>**</span><span class='lparen'>(</span><span class='id identifier rubyid_exponent'>exponent</span><span class='rparen'>)</span>
|
|
2117
|
-
<span class='kw'>return</span> <span class='id identifier rubyid_copy_with'>copy_with</span><span class='lparen'>(</span><span class='label'>amount:</span> <span class='id identifier rubyid_amount'>amount</span><span class='op'>**</span><span class='id identifier rubyid_exponent'>exponent</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_exponent'>exponent</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Numeric</span><span class='rparen'>)</span>
|
|
2438
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_copy_with'>copy_with</span><span class='lparen'>(</span><span class='label'>amount:</span> <span class='id identifier rubyid_amount'>amount</span><span class='op'>**</span><span class='id identifier rubyid_exponent'>exponent</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_exponent'>exponent</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></span><span class='rparen'>)</span>
|
|
2118
2439
|
|
|
2119
2440
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'> can't be powered by </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exponent'>exponent</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
|
2120
2441
|
<span class='kw'>end</span></pre>
|
|
@@ -2147,7 +2468,7 @@ is not registered</p></div>
|
|
|
2147
2468
|
<span class='name'>addend</span>
|
|
2148
2469
|
|
|
2149
2470
|
|
|
2150
|
-
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt>Numeric</tt>)</span>
|
|
2471
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
2151
2472
|
|
|
2152
2473
|
|
|
2153
2474
|
|
|
@@ -2244,7 +2565,7 @@ is not registered</p></div>
|
|
|
2244
2565
|
<span class='name'>subtrahend</span>
|
|
2245
2566
|
|
|
2246
2567
|
|
|
2247
|
-
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt>Numeric</tt>)</span>
|
|
2568
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
2248
2569
|
|
|
2249
2570
|
|
|
2250
2571
|
|
|
@@ -2371,7 +2692,7 @@ is not registered</p></div>
|
|
|
2371
2692
|
<div class="method_details ">
|
|
2372
2693
|
<h3 class="signature " id="/-instance_method">
|
|
2373
2694
|
|
|
2374
|
-
#<strong>/</strong>(divisor) ⇒ <tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt>Numeric</tt>
|
|
2695
|
+
#<strong>/</strong>(divisor) ⇒ <tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>
|
|
2375
2696
|
|
|
2376
2697
|
|
|
2377
2698
|
|
|
@@ -2392,7 +2713,7 @@ is not registered</p></div>
|
|
|
2392
2713
|
<span class='name'>divisor</span>
|
|
2393
2714
|
|
|
2394
2715
|
|
|
2395
|
-
<span class='type'>(<tt>Numeric</tt>, <tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>)</span>
|
|
2716
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>, <tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>)</span>
|
|
2396
2717
|
|
|
2397
2718
|
|
|
2398
2719
|
|
|
@@ -2409,7 +2730,7 @@ is not registered</p></div>
|
|
|
2409
2730
|
<li>
|
|
2410
2731
|
|
|
2411
2732
|
|
|
2412
|
-
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt>Numeric</tt>)</span>
|
|
2733
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
2413
2734
|
|
|
2414
2735
|
|
|
2415
2736
|
|
|
@@ -2467,7 +2788,7 @@ is not registered</p></div>
|
|
|
2467
2788
|
|
|
2468
2789
|
<span class='kw'>def</span> <span class='op'>/</span><span class='lparen'>(</span><span class='id identifier rubyid_divisor'>divisor</span><span class='rparen'>)</span>
|
|
2469
2790
|
<span class='kw'>case</span> <span class='id identifier rubyid_divisor'>divisor</span>
|
|
2470
|
-
<span class='kw'>when</span> <span class='const'>Numeric</span> <span class='kw'>then</span> <span class='kw'>return</span> <span class='id identifier rubyid_copy_with'>copy_with</span><span class='lparen'>(</span><span class='label'>amount:</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>/</span> <span class='id identifier rubyid_divisor'>divisor</span><span class='rparen'>)</span>
|
|
2791
|
+
<span class='kw'>when</span> <span class='const'><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></span> <span class='kw'>then</span> <span class='kw'>return</span> <span class='id identifier rubyid_copy_with'>copy_with</span><span class='lparen'>(</span><span class='label'>amount:</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>/</span> <span class='id identifier rubyid_divisor'>divisor</span><span class='rparen'>)</span>
|
|
2471
2792
|
<span class='kw'>when</span> <span class='const'><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></span> <span class='kw'>then</span> <span class='kw'>return</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>/</span> <span class='id identifier rubyid_divisor'>divisor</span><span class='period'>.</span><span class='id identifier rubyid_amount'>amount</span> <span class='kw'>if</span> <span class='id identifier rubyid_same_currency?'>same_currency?</span> <span class='id identifier rubyid_divisor'>divisor</span>
|
|
2472
2793
|
<span class='kw'>end</span>
|
|
2473
2794
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'> can't be divided by </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_divisor'>divisor</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
|
@@ -2488,7 +2809,11 @@ is not registered</p></div>
|
|
|
2488
2809
|
|
|
2489
2810
|
</h3><div class="docstring">
|
|
2490
2811
|
<div class="discussion">
|
|
2491
|
-
|
|
2812
|
+
<p class="note private">
|
|
2813
|
+
<strong>This method is part of a private API.</strong>
|
|
2814
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
2815
|
+
</p>
|
|
2816
|
+
|
|
2492
2817
|
|
|
2493
2818
|
</div>
|
|
2494
2819
|
</div>
|
|
@@ -2549,7 +2874,11 @@ two_usd > Mint.money(2, 'BRL')
|
|
|
2549
2874
|
|
|
2550
2875
|
</h3><div class="docstring">
|
|
2551
2876
|
<div class="discussion">
|
|
2552
|
-
<p
|
|
2877
|
+
<p class="note private">
|
|
2878
|
+
<strong>This method is part of a private API.</strong>
|
|
2879
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
2880
|
+
</p>
|
|
2881
|
+
<p>Returns true if both are zero, or both have same amount and same currency.</p>
|
|
2553
2882
|
|
|
2554
2883
|
</div>
|
|
2555
2884
|
</div>
|
|
@@ -2688,7 +3017,7 @@ Disperses any subunit rounding amounts across the initial slots</p>
|
|
|
2688
3017
|
<span class='name'>proportions</span>
|
|
2689
3018
|
|
|
2690
3019
|
|
|
2691
|
-
<span class='type'>(<tt>Array<
|
|
3020
|
+
<span class='type'>(<tt>Array<<span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span>></tt>)</span>
|
|
2692
3021
|
|
|
2693
3022
|
|
|
2694
3023
|
|
|
@@ -2761,6 +3090,80 @@ Disperses any subunit rounding amounts across the initial slots</p>
|
|
|
2761
3090
|
</td>
|
|
2762
3091
|
</tr>
|
|
2763
3092
|
</table>
|
|
3093
|
+
</div>
|
|
3094
|
+
|
|
3095
|
+
<div class="method_details ">
|
|
3096
|
+
<h3 class="signature " id="amount_to_s-instance_method">
|
|
3097
|
+
|
|
3098
|
+
#<strong>amount_to_s</strong>(thousand: ',') ⇒ <tt>Object</tt>
|
|
3099
|
+
|
|
3100
|
+
|
|
3101
|
+
|
|
3102
|
+
|
|
3103
|
+
|
|
3104
|
+
</h3><table class="source_code">
|
|
3105
|
+
<tr>
|
|
3106
|
+
<td>
|
|
3107
|
+
<pre class="lines">
|
|
3108
|
+
|
|
3109
|
+
|
|
3110
|
+
115
|
|
3111
|
+
116
|
|
3112
|
+
117
|
|
3113
|
+
118
|
|
3114
|
+
119
|
|
3115
|
+
120
|
|
3116
|
+
121
|
|
3117
|
+
122
|
|
3118
|
+
123
|
|
3119
|
+
124
|
|
3120
|
+
125
|
|
3121
|
+
126
|
|
3122
|
+
127
|
|
3123
|
+
128
|
|
3124
|
+
129
|
|
3125
|
+
130
|
|
3126
|
+
131
|
|
3127
|
+
132
|
|
3128
|
+
133
|
|
3129
|
+
134
|
|
3130
|
+
135
|
|
3131
|
+
136
|
|
3132
|
+
137
|
|
3133
|
+
138
|
|
3134
|
+
139</pre>
|
|
3135
|
+
</td>
|
|
3136
|
+
<td>
|
|
3137
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/format/to_s.rb', line 115</span>
|
|
3138
|
+
|
|
3139
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_amount_to_s'>amount_to_s</span><span class='lparen'>(</span><span class='label'>thousand:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
3140
|
+
<span class='id identifier rubyid_subunit'>subunit</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_subunit'>subunit</span>
|
|
3141
|
+
<span class='id identifier rubyid_numeric'>numeric</span> <span class='op'>=</span> <span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</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'>f</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span>
|
|
3142
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_numeric'>numeric</span> <span class='kw'>if</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>></span> <span class='op'>-</span><span class='int'>1000</span> <span class='op'>&&</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'><</span> <span class='int'>1000</span>
|
|
3143
|
+
|
|
3144
|
+
<span class='id identifier rubyid_numeric'>numeric</span><span class='period'>.</span><span class='id identifier rubyid_reverse!'>reverse!</span>
|
|
3145
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_subunit'>subunit</span> <span class='op'>></span> <span class='int'>0</span>
|
|
3146
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_numeric'>numeric</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_subunit'>subunit</span> <span class='op'>+</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
|
3147
|
+
<span class='id identifier rubyid_integral'>integral</span> <span class='op'>=</span> <span class='id identifier rubyid_numeric'>numeric</span><span class='lbracket'>[</span><span class='id identifier rubyid_subunit'>subunit</span> <span class='op'>+</span> <span class='int'>1</span><span class='comma'>,</span> <span class='id identifier rubyid_numeric'>numeric</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>-</span> <span class='int'>1</span><span class='rbracket'>]</span>
|
|
3148
|
+
<span class='kw'>else</span>
|
|
3149
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
|
3150
|
+
<span class='id identifier rubyid_integral'>integral</span> <span class='op'>=</span> <span class='id identifier rubyid_numeric'>numeric</span>
|
|
3151
|
+
<span class='kw'>end</span>
|
|
3152
|
+
|
|
3153
|
+
<span class='id identifier rubyid_length'>length</span> <span class='op'>=</span> <span class='id identifier rubyid_integral'>integral</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
|
3154
|
+
|
|
3155
|
+
<span class='comment'>#puts "numeric: #{numeric} subunit: #{subunit} result: <#{result}> integral:#{integral}" if self == Mint.money(-123_456_789.01, 'USD')
|
|
3156
|
+
</span>
|
|
3157
|
+
<span class='id identifier rubyid_integral'>integral</span><span class='period'>.</span><span class='id identifier rubyid_chars'>chars</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_char'>char</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='op'>|</span>
|
|
3158
|
+
<span class='id identifier rubyid_remaining'>remaining</span> <span class='op'>=</span> <span class='id identifier rubyid_length'>length</span> <span class='op'>-</span> <span class='id identifier rubyid_index'>index</span>
|
|
3159
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'><<</span> <span class='id identifier rubyid_thousand'>thousand</span> <span class='kw'>if</span> <span class='id identifier rubyid_index'>index</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>&&</span> <span class='id identifier rubyid_remaining'>remaining</span> <span class='op'>></span> <span class='int'>0</span> <span class='op'>&&</span> <span class='id identifier rubyid_index'>index</span> <span class='op'>%</span> <span class='int'>3</span> <span class='op'>==</span> <span class='int'>0</span> <span class='op'>&&</span> <span class='id identifier rubyid_char'>char</span> <span class='op'>!=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>-</span><span class='tstring_end'>'</span></span>
|
|
3160
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'><<</span> <span class='id identifier rubyid_char'>char</span>
|
|
3161
|
+
<span class='kw'>end</span>
|
|
3162
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_reverse'>reverse</span>
|
|
3163
|
+
<span class='kw'>end</span></pre>
|
|
3164
|
+
</td>
|
|
3165
|
+
</tr>
|
|
3166
|
+
</table>
|
|
2764
3167
|
</div>
|
|
2765
3168
|
|
|
2766
3169
|
<div class="method_details ">
|
|
@@ -2827,7 +3230,7 @@ frozen <span class='object_link'><a href="" title="Mint::Money (class)">Mint::Mo
|
|
|
2827
3230
|
<span class='name'>min_or_range</span>
|
|
2828
3231
|
|
|
2829
3232
|
|
|
2830
|
-
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt>Numeric</tt>, <tt>Range</tt>, <tt>nil</tt>)</span>
|
|
3233
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>, <tt>Range</tt>, <tt>nil</tt>)</span>
|
|
2831
3234
|
|
|
2832
3235
|
|
|
2833
3236
|
|
|
@@ -2841,7 +3244,7 @@ frozen <span class='object_link'><a href="" title="Mint::Money (class)">Mint::Mo
|
|
|
2841
3244
|
<span class='name'>max</span>
|
|
2842
3245
|
|
|
2843
3246
|
|
|
2844
|
-
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt>Numeric</tt>, <tt>nil</tt>)</span>
|
|
3247
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></tt>, <tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>, <tt>nil</tt>)</span>
|
|
2845
3248
|
|
|
2846
3249
|
|
|
2847
3250
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
@@ -2962,7 +3365,7 @@ This enables expressions like <code>5 * money</code> where <code>5</code> is a N
|
|
|
2962
3365
|
<span class='name'>other</span>
|
|
2963
3366
|
|
|
2964
3367
|
|
|
2965
|
-
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
3368
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
2966
3369
|
|
|
2967
3370
|
|
|
2968
3371
|
|
|
@@ -3047,7 +3450,7 @@ while preserving immutability.</p>
|
|
|
3047
3450
|
<span class='name'>amount</span>
|
|
3048
3451
|
|
|
3049
3452
|
|
|
3050
|
-
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
3453
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
3051
3454
|
|
|
3052
3455
|
|
|
3053
3456
|
|
|
@@ -3081,20 +3484,20 @@ while preserving immutability.</p>
|
|
|
3081
3484
|
<pre class="lines">
|
|
3082
3485
|
|
|
3083
3486
|
|
|
3487
|
+
104
|
|
3488
|
+
105
|
|
3489
|
+
106
|
|
3490
|
+
107
|
|
3491
|
+
108
|
|
3492
|
+
109
|
|
3084
3493
|
110
|
|
3085
3494
|
111
|
|
3086
3495
|
112
|
|
3087
3496
|
113
|
|
3088
|
-
114
|
|
3089
|
-
115
|
|
3090
|
-
116
|
|
3091
|
-
117
|
|
3092
|
-
118
|
|
3093
|
-
119
|
|
3094
|
-
120</pre>
|
|
3497
|
+
114</pre>
|
|
3095
3498
|
</td>
|
|
3096
3499
|
<td>
|
|
3097
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
3500
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 104</span>
|
|
3098
3501
|
|
|
3099
3502
|
<span class='kw'>def</span> <span class='id identifier rubyid_copy_with'>copy_with</span><span class='lparen'>(</span><span class='label'>amount:</span><span class='rparen'>)</span>
|
|
3100
3503
|
<span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_normalize_amount'>normalize_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span>
|
|
@@ -3115,7 +3518,7 @@ while preserving immutability.</p>
|
|
|
3115
3518
|
<div class="method_details ">
|
|
3116
3519
|
<h3 class="signature " id="currency_code-instance_method">
|
|
3117
3520
|
|
|
3118
|
-
#<strong>currency_code</strong> ⇒ <tt>String</tt>
|
|
3521
|
+
#<strong>currency_code</strong> ⇒ <tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>
|
|
3119
3522
|
|
|
3120
3523
|
|
|
3121
3524
|
|
|
@@ -3143,7 +3546,7 @@ while preserving immutability.</p>
|
|
|
3143
3546
|
<li>
|
|
3144
3547
|
|
|
3145
3548
|
|
|
3146
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
3549
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
3147
3550
|
|
|
3148
3551
|
|
|
3149
3552
|
|
|
@@ -3160,10 +3563,10 @@ while preserving immutability.</p>
|
|
|
3160
3563
|
<pre class="lines">
|
|
3161
3564
|
|
|
3162
3565
|
|
|
3163
|
-
|
|
3566
|
+
27</pre>
|
|
3164
3567
|
</td>
|
|
3165
3568
|
<td>
|
|
3166
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
3569
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 27</span>
|
|
3167
3570
|
|
|
3168
3571
|
<span class='kw'>def</span> <span class='id identifier rubyid_currency_code'>currency_code</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span></pre>
|
|
3169
3572
|
</td>
|
|
@@ -3182,7 +3585,11 @@ while preserving immutability.</p>
|
|
|
3182
3585
|
|
|
3183
3586
|
</h3><div class="docstring">
|
|
3184
3587
|
<div class="discussion">
|
|
3185
|
-
<p
|
|
3588
|
+
<p class="note private">
|
|
3589
|
+
<strong>This method is part of a private API.</strong>
|
|
3590
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
3591
|
+
</p>
|
|
3592
|
+
<p>Strict equality — both amount and currency must match exactly.
|
|
3186
3593
|
Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
3187
3594
|
|
|
3188
3595
|
</div>
|
|
@@ -3226,6 +3633,265 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3226
3633
|
</td>
|
|
3227
3634
|
</tr>
|
|
3228
3635
|
</table>
|
|
3636
|
+
</div>
|
|
3637
|
+
|
|
3638
|
+
<div class="method_details ">
|
|
3639
|
+
<h3 class="signature " id="format-instance_method">
|
|
3640
|
+
|
|
3641
|
+
#<strong>format</strong>(preset = nil, format: nil, decimal: nil, thousand: nil, width: nil) ⇒ <tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>
|
|
3642
|
+
|
|
3643
|
+
|
|
3644
|
+
|
|
3645
|
+
<span class="aliases">Also known as:
|
|
3646
|
+
<span class="names"><span id='to_fs-instance_method'>to_fs</span></span>
|
|
3647
|
+
</span>
|
|
3648
|
+
|
|
3649
|
+
|
|
3650
|
+
|
|
3651
|
+
</h3><div class="docstring">
|
|
3652
|
+
<div class="discussion">
|
|
3653
|
+
<p>Formats money as a string with customizable format, thousand delimiter, and decimal</p>
|
|
3654
|
+
|
|
3655
|
+
</div>
|
|
3656
|
+
</div>
|
|
3657
|
+
<div class="tags">
|
|
3658
|
+
|
|
3659
|
+
<div class="examples">
|
|
3660
|
+
<h4 class="tag_title">Examples:</h4>
|
|
3661
|
+
|
|
3662
|
+
|
|
3663
|
+
<h5 class="example_title"><div class='inline'><p>Basic formatting</p></div></h5>
|
|
3664
|
+
|
|
3665
|
+
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='float'>1234.56</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>USD</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
3666
|
+
<span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span> <span class='comment'>#=> "$1,234.56"
|
|
3667
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>thousand:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>decimal:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$1.234,56"
|
|
3668
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>decimal:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>thousand:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$1234,56"</span></code></pre>
|
|
3669
|
+
|
|
3670
|
+
|
|
3671
|
+
<h5 class="example_title"><div class='inline'><p>Preset formats</p></div></h5>
|
|
3672
|
+
|
|
3673
|
+
<pre class="example code"><code><span class='id identifier rubyid_loss'>loss</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='op'>-</span><span class='float'>1234.56</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>USD</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
3674
|
+
<span class='id identifier rubyid_loss'>loss</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='symbol'>:accounting</span><span class='rparen'>)</span> <span class='comment'>#=> "($1,234.56)"
|
|
3675
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='symbol'>:european</span><span class='rparen'>)</span> <span class='comment'>#=> "1.234,56 €"
|
|
3676
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='symbol'>:amount</span><span class='rparen'>)</span> <span class='comment'>#=> "1234.56"
|
|
3677
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='symbol'>:currency</span><span class='rparen'>)</span> <span class='comment'>#=> "USD 1234.56"</span></code></pre>
|
|
3678
|
+
|
|
3679
|
+
|
|
3680
|
+
<h5 class="example_title"><div class='inline'><p>Custom formats</p></div></h5>
|
|
3681
|
+
|
|
3682
|
+
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "1234.56"
|
|
3683
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<currency>s %<amount>f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "USD 1234.56"
|
|
3684
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>f %<symbol>s</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "1234.56 $"
|
|
3685
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<symbol>s%<amount>+f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$+1234.56"</span></code></pre>
|
|
3686
|
+
|
|
3687
|
+
|
|
3688
|
+
<h5 class="example_title"><div class='inline'><p>Integral & fractional parts</p></div></h5>
|
|
3689
|
+
|
|
3690
|
+
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<integral>d.%<fractional>02d</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "1234.56"
|
|
3691
|
+
</span><span class='id identifier rubyid_price'>price</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='float'>0.99</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>USD</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
3692
|
+
<span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<integral>d dollars and %<fractional>02d cents</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
3693
|
+
<span class='comment'>#=> "0 dollars and 99 cents"</span></code></pre>
|
|
3694
|
+
|
|
3695
|
+
|
|
3696
|
+
<h5 class="example_title"><div class='inline'><p>Per-sign Hash format (accounting parentheses)</p></div></h5>
|
|
3697
|
+
|
|
3698
|
+
<pre class="example code"><code><span class='id identifier rubyid_loss'>loss</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='op'>-</span><span class='float'>1234.56</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>USD</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
3699
|
+
<span class='id identifier rubyid_loss'>loss</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>negative:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>(%<symbol>s%<amount>f)</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>#=> "($1,234.56)"
|
|
3700
|
+
</span><span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BRL</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>zero:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>--</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>#=> "--"</span></code></pre>
|
|
3701
|
+
|
|
3702
|
+
|
|
3703
|
+
<h5 class="example_title"><div class='inline'><p>Padding and alignment</p></div></h5>
|
|
3704
|
+
|
|
3705
|
+
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>10.2f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> " 1234.56"
|
|
3706
|
+
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<symbol>s%<amount>010.2f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$0001234.56"</span></code></pre>
|
|
3707
|
+
|
|
3708
|
+
|
|
3709
|
+
<h5 class="example_title"><div class='inline'><p>Locale-aware formatting (with Mint.locale_backend set)</p></div></h5>
|
|
3710
|
+
|
|
3711
|
+
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span> <span class='comment'># decimal and thousand come from locale_backend</span></code></pre>
|
|
3712
|
+
|
|
3713
|
+
</div>
|
|
3714
|
+
<p class="tag_title">Parameters:</p>
|
|
3715
|
+
<ul class="param">
|
|
3716
|
+
|
|
3717
|
+
<li>
|
|
3718
|
+
|
|
3719
|
+
<span class='name'>preset</span>
|
|
3720
|
+
|
|
3721
|
+
|
|
3722
|
+
<span class='type'>(<tt>Symbol</tt>, <tt>nil</tt>)</span>
|
|
3723
|
+
|
|
3724
|
+
|
|
3725
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
3726
|
+
|
|
3727
|
+
|
|
3728
|
+
—
|
|
3729
|
+
<div class='inline'><p>Named format preset, one of:
|
|
3730
|
+
<code>:accounting</code>, <code>:european</code>, <code>:amount</code>, <code>:currency</code>.
|
|
3731
|
+
When provided, expands to the preset's format options and merges
|
|
3732
|
+
with any explicit keyword arguments (kwargs override the preset).</p></div>
|
|
3733
|
+
|
|
3734
|
+
</li>
|
|
3735
|
+
|
|
3736
|
+
<li>
|
|
3737
|
+
|
|
3738
|
+
<span class='name'>format</span>
|
|
3739
|
+
|
|
3740
|
+
|
|
3741
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>, <tt>Hash</tt>, <tt>nil</tt>)</span>
|
|
3742
|
+
|
|
3743
|
+
|
|
3744
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
3745
|
+
|
|
3746
|
+
|
|
3747
|
+
—
|
|
3748
|
+
<div class='inline'><p>Either a Format string with placeholders
|
|
3749
|
+
(%<symbol>s, %<amount>f, %<currency>s, %<integral>d, %<fractional>d, %<dsymbol>s),
|
|
3750
|
+
or a Hash with per-sign keys (:positive, :negative, :zero) each
|
|
3751
|
+
holding a format string. A Hash is convenient for sign-aware formats
|
|
3752
|
+
such as accounting parentheses:</p>
|
|
3753
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>negative:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>(%<symbol>s%<amount>f)</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
3754
|
+
</code></pre>
|
|
3755
|
+
<p>Missing keys fall back to the module default, so a Hash with only
|
|
3756
|
+
:negative will still format positives sensibly. The valid keys are
|
|
3757
|
+
:positive, :negative, :zero; anything else raises ArgumentError.
|
|
3758
|
+
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise
|
|
3759
|
+
<code>"%<symbol>s%<amount>f"</code>.</p></div>
|
|
3760
|
+
|
|
3761
|
+
</li>
|
|
3762
|
+
|
|
3763
|
+
<li>
|
|
3764
|
+
|
|
3765
|
+
<span class='name'>thousand</span>
|
|
3766
|
+
|
|
3767
|
+
|
|
3768
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>, <tt>false</tt>, <tt>nil</tt>)</span>
|
|
3769
|
+
|
|
3770
|
+
|
|
3771
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
3772
|
+
|
|
3773
|
+
|
|
3774
|
+
—
|
|
3775
|
+
<div class='inline'><p>Thousands delimiter (e.g., ',' for 1,000).
|
|
3776
|
+
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise <code>","</code>.</p></div>
|
|
3777
|
+
|
|
3778
|
+
</li>
|
|
3779
|
+
|
|
3780
|
+
<li>
|
|
3781
|
+
|
|
3782
|
+
<span class='name'>decimal</span>
|
|
3783
|
+
|
|
3784
|
+
|
|
3785
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>, <tt>nil</tt>)</span>
|
|
3786
|
+
|
|
3787
|
+
|
|
3788
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
3789
|
+
|
|
3790
|
+
|
|
3791
|
+
—
|
|
3792
|
+
<div class='inline'><p>Decimal separator (e.g., '.' or ',').
|
|
3793
|
+
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise <code>"."</code>.</p></div>
|
|
3794
|
+
|
|
3795
|
+
</li>
|
|
3796
|
+
|
|
3797
|
+
</ul>
|
|
3798
|
+
|
|
3799
|
+
<p class="tag_title">Returns:</p>
|
|
3800
|
+
<ul class="return">
|
|
3801
|
+
|
|
3802
|
+
<li>
|
|
3803
|
+
|
|
3804
|
+
|
|
3805
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
3806
|
+
|
|
3807
|
+
|
|
3808
|
+
|
|
3809
|
+
—
|
|
3810
|
+
<div class='inline'><p>Formatted money string</p></div>
|
|
3811
|
+
|
|
3812
|
+
</li>
|
|
3813
|
+
|
|
3814
|
+
</ul>
|
|
3815
|
+
<p class="tag_title">Raises:</p>
|
|
3816
|
+
<ul class="raise">
|
|
3817
|
+
|
|
3818
|
+
<li>
|
|
3819
|
+
|
|
3820
|
+
|
|
3821
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
3822
|
+
|
|
3823
|
+
|
|
3824
|
+
|
|
3825
|
+
—
|
|
3826
|
+
<div class='inline'><p>if <code>preset</code> is not a recognised name, or if
|
|
3827
|
+
<code>format</code> is not a String or Hash, the Hash is empty, or the Hash
|
|
3828
|
+
contains an unrecognised key.</p></div>
|
|
3829
|
+
|
|
3830
|
+
</li>
|
|
3831
|
+
|
|
3832
|
+
</ul>
|
|
3833
|
+
|
|
3834
|
+
</div><table class="source_code">
|
|
3835
|
+
<tr>
|
|
3836
|
+
<td>
|
|
3837
|
+
<pre class="lines">
|
|
3838
|
+
|
|
3839
|
+
|
|
3840
|
+
85
|
|
3841
|
+
86
|
|
3842
|
+
87
|
|
3843
|
+
88
|
|
3844
|
+
89
|
|
3845
|
+
90
|
|
3846
|
+
91
|
|
3847
|
+
92
|
|
3848
|
+
93
|
|
3849
|
+
94
|
|
3850
|
+
95
|
|
3851
|
+
96
|
|
3852
|
+
97
|
|
3853
|
+
98
|
|
3854
|
+
99
|
|
3855
|
+
100
|
|
3856
|
+
101
|
|
3857
|
+
102
|
|
3858
|
+
103
|
|
3859
|
+
104
|
|
3860
|
+
105
|
|
3861
|
+
106
|
|
3862
|
+
107
|
|
3863
|
+
108</pre>
|
|
3864
|
+
</td>
|
|
3865
|
+
<td>
|
|
3866
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/format/to_s.rb', line 85</span>
|
|
3867
|
+
|
|
3868
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='id identifier rubyid_preset'>preset</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>format:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>decimal:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>thousand:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>width:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
3869
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_preset'>preset</span>
|
|
3870
|
+
<span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#PRESETS-constant" title="Mint::Money::PRESETS (constant)">PRESETS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_preset'>preset</span><span class='rparen'>)</span> <span class='lbrace'>{</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'>Unknown format preset: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_preset'>preset</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
|
3871
|
+
<span class='id identifier rubyid_format'>format</span> <span class='op'>||=</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:format</span><span class='rbracket'>]</span>
|
|
3872
|
+
<span class='id identifier rubyid_decimal'>decimal</span> <span class='op'>||=</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:decimal</span><span class='rbracket'>]</span>
|
|
3873
|
+
<span class='id identifier rubyid_thousand'>thousand</span> <span class='op'>||=</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:thousand</span><span class='rbracket'>]</span>
|
|
3874
|
+
<span class='id identifier rubyid_width'>width</span> <span class='op'>||=</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:width</span><span class='rbracket'>]</span>
|
|
3875
|
+
<span class='kw'>end</span>
|
|
3876
|
+
|
|
3877
|
+
<span class='id identifier rubyid_validate_separators!'>validate_separators!</span><span class='lparen'>(</span><span class='label'>decimal:</span><span class='comma'>,</span> <span class='label'>thousand:</span><span class='rparen'>)</span>
|
|
3878
|
+
|
|
3879
|
+
<span class='id identifier rubyid_format'>format</span><span class='comma'>,</span> <span class='id identifier rubyid_decimal'>decimal</span><span class='comma'>,</span> <span class='id identifier rubyid_thousand'>thousand</span> <span class='op'>=</span> <span class='id identifier rubyid_resolve_locale_for'>resolve_locale_for</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='comma'>,</span> <span class='id identifier rubyid_decimal'>decimal</span><span class='comma'>,</span> <span class='id identifier rubyid_thousand'>thousand</span><span class='rparen'>)</span>
|
|
3880
|
+
|
|
3881
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_format'>format</span>
|
|
3882
|
+
<span class='kw'>when</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span> <span class='kw'>then</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'>format must not be empty</span><span class='tstring_end'>'</span></span>
|
|
3883
|
+
<span class='kw'>when</span> <span class='const'>Hash</span> <span class='kw'>then</span> <span class='id identifier rubyid_validate_format_hash'>validate_format_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
|
|
3884
|
+
<span class='kw'>when</span> <span class='const'><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></span> <span class='kw'>then</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>positive:</span> <span class='id identifier rubyid_format'>format</span> <span class='rbrace'>}</span>
|
|
3885
|
+
<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'>Invalid format. Only String or Hash are accepted</span><span class='tstring_end'>'</span></span>
|
|
3886
|
+
<span class='kw'>end</span>
|
|
3887
|
+
|
|
3888
|
+
<span class='id identifier rubyid_formatted'>formatted</span> <span class='op'>=</span> <span class='id identifier rubyid_format_amount'>format_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='comma'>,</span> <span class='label'>decimal:</span> <span class='id identifier rubyid_decimal'>decimal</span><span class='comma'>,</span> <span class='label'>thousand:</span> <span class='id identifier rubyid_thousand'>thousand</span><span class='rparen'>)</span>
|
|
3889
|
+
|
|
3890
|
+
<span class='id identifier rubyid_width'>width</span> <span class='op'>?</span> <span class='id identifier rubyid_formatted'>formatted</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_formatted'>formatted</span>
|
|
3891
|
+
<span class='kw'>end</span></pre>
|
|
3892
|
+
</td>
|
|
3893
|
+
</tr>
|
|
3894
|
+
</table>
|
|
3229
3895
|
</div>
|
|
3230
3896
|
|
|
3231
3897
|
<div class="method_details ">
|
|
@@ -3262,10 +3928,10 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3262
3928
|
<pre class="lines">
|
|
3263
3929
|
|
|
3264
3930
|
|
|
3265
|
-
|
|
3931
|
+
44</pre>
|
|
3266
3932
|
</td>
|
|
3267
3933
|
<td>
|
|
3268
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
3934
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 44</span>
|
|
3269
3935
|
|
|
3270
3936
|
<span class='kw'>def</span> <span class='id identifier rubyid_fractional'>fractional</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_abs'>abs</span> <span class='op'>%</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='op'>*</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span></pre>
|
|
3271
3937
|
</td>
|
|
@@ -3313,10 +3979,10 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3313
3979
|
<pre class="lines">
|
|
3314
3980
|
|
|
3315
3981
|
|
|
3316
|
-
|
|
3982
|
+
49</pre>
|
|
3317
3983
|
</td>
|
|
3318
3984
|
<td>
|
|
3319
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
3985
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 49</span>
|
|
3320
3986
|
|
|
3321
3987
|
<span class='kw'>def</span> <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_currency_code'>currency_code</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span></pre>
|
|
3322
3988
|
</td>
|
|
@@ -3327,7 +3993,7 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3327
3993
|
<div class="method_details ">
|
|
3328
3994
|
<h3 class="signature " id="inspect-instance_method">
|
|
3329
3995
|
|
|
3330
|
-
#<strong>inspect</strong> ⇒ <tt>String</tt>
|
|
3996
|
+
#<strong>inspect</strong> ⇒ <tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>
|
|
3331
3997
|
|
|
3332
3998
|
|
|
3333
3999
|
|
|
@@ -3347,7 +4013,7 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3347
4013
|
<li>
|
|
3348
4014
|
|
|
3349
4015
|
|
|
3350
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
4016
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
3351
4017
|
|
|
3352
4018
|
|
|
3353
4019
|
|
|
@@ -3364,12 +4030,12 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3364
4030
|
<pre class="lines">
|
|
3365
4031
|
|
|
3366
4032
|
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
4033
|
+
54
|
|
4034
|
+
55
|
|
4035
|
+
56</pre>
|
|
3370
4036
|
</td>
|
|
3371
4037
|
<td>
|
|
3372
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
4038
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 54</span>
|
|
3373
4039
|
|
|
3374
4040
|
<span class='kw'>def</span> <span class='id identifier rubyid_inspect'>inspect</span>
|
|
3375
4041
|
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency_code'>currency_code</span><span class='embexpr_end'>}</span><span class='tstring_content'> %0.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_subunit'>subunit</span><span class='embexpr_end'>}</span><span class='tstring_content'>f]</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_amount'>amount</span>
|
|
@@ -3412,7 +4078,7 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3412
4078
|
<span class='name'>new_amount</span>
|
|
3413
4079
|
|
|
3414
4080
|
|
|
3415
|
-
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
4081
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Numeric.html" title="Numeric (class)">Numeric</a></span></tt>)</span>
|
|
3416
4082
|
|
|
3417
4083
|
|
|
3418
4084
|
|
|
@@ -3446,13 +4112,13 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3446
4112
|
<pre class="lines">
|
|
3447
4113
|
|
|
3448
4114
|
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
4115
|
+
123
|
|
4116
|
+
124
|
|
4117
|
+
125
|
|
4118
|
+
126</pre>
|
|
3453
4119
|
</td>
|
|
3454
4120
|
<td>
|
|
3455
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
4121
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 123</span>
|
|
3456
4122
|
|
|
3457
4123
|
<span class='kw'>def</span> <span class='id identifier rubyid_mint'>mint</span><span class='lparen'>(</span><span class='id identifier rubyid_new_amount'>new_amount</span><span class='rparen'>)</span>
|
|
3458
4124
|
<span class='id identifier rubyid_warn'>warn</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Money#mint is now deprecated and will be removed in v2</span><span class='tstring_end'>'</span></span>
|
|
@@ -3525,7 +4191,11 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3525
4191
|
|
|
3526
4192
|
</h3><div class="docstring">
|
|
3527
4193
|
<div class="discussion">
|
|
3528
|
-
<p
|
|
4194
|
+
<p class="note private">
|
|
4195
|
+
<strong>This method is part of a private API.</strong>
|
|
4196
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4197
|
+
</p>
|
|
4198
|
+
<p>Returns self if amount is non-zero, nil otherwise.</p>
|
|
3529
4199
|
|
|
3530
4200
|
</div>
|
|
3531
4201
|
</div>
|
|
@@ -3627,7 +4297,11 @@ Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
|
3627
4297
|
|
|
3628
4298
|
</h3><div class="docstring">
|
|
3629
4299
|
<div class="discussion">
|
|
3630
|
-
<p
|
|
4300
|
+
<p class="note private">
|
|
4301
|
+
<strong>This method is part of a private API.</strong>
|
|
4302
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4303
|
+
</p>
|
|
4304
|
+
<p>Helper method to verify if another Money has the identical currency.</p>
|
|
3631
4305
|
|
|
3632
4306
|
</div>
|
|
3633
4307
|
</div>
|
|
@@ -3846,10 +4520,10 @@ For example, cents for USD (subunit 2), yen for JPY (subunit 0), fils for IQD (s
|
|
|
3846
4520
|
<pre class="lines">
|
|
3847
4521
|
|
|
3848
4522
|
|
|
3849
|
-
|
|
4523
|
+
37</pre>
|
|
3850
4524
|
</td>
|
|
3851
4525
|
<td>
|
|
3852
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
4526
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 37</span>
|
|
3853
4527
|
|
|
3854
4528
|
<span class='kw'>def</span> <span class='id identifier rubyid_subunits'>subunits</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span> <span class='op'>*</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span></pre>
|
|
3855
4529
|
</td>
|
|
@@ -3920,7 +4594,11 @@ Enables standard ranges and stepping (e.g. <code>1.dollar..10.dollars</code>).</
|
|
|
3920
4594
|
|
|
3921
4595
|
</h3><div class="docstring">
|
|
3922
4596
|
<div class="discussion">
|
|
3923
|
-
<p
|
|
4597
|
+
<p class="note private">
|
|
4598
|
+
<strong>This method is part of a private API.</strong>
|
|
4599
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4600
|
+
</p>
|
|
4601
|
+
<p>Converts the monetary amount to a BigDecimal object.</p>
|
|
3924
4602
|
|
|
3925
4603
|
</div>
|
|
3926
4604
|
</div>
|
|
@@ -3957,10 +4635,10 @@ Enables standard ranges and stepping (e.g. <code>1.dollar..10.dollars</code>).</
|
|
|
3957
4635
|
<pre class="lines">
|
|
3958
4636
|
|
|
3959
4637
|
|
|
3960
|
-
|
|
4638
|
+
15</pre>
|
|
3961
4639
|
</td>
|
|
3962
4640
|
<td>
|
|
3963
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line
|
|
4641
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line 15</span>
|
|
3964
4642
|
|
|
3965
4643
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_d'>to_d</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_d'>to_d</span> <span class='int'>0</span></pre>
|
|
3966
4644
|
</td>
|
|
@@ -3979,7 +4657,11 @@ Enables standard ranges and stepping (e.g. <code>1.dollar..10.dollars</code>).</
|
|
|
3979
4657
|
|
|
3980
4658
|
</h3><div class="docstring">
|
|
3981
4659
|
<div class="discussion">
|
|
3982
|
-
<p
|
|
4660
|
+
<p class="note private">
|
|
4661
|
+
<strong>This method is part of a private API.</strong>
|
|
4662
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4663
|
+
</p>
|
|
4664
|
+
<p>Converts the monetary amount to a standard float.
|
|
3983
4665
|
Note: Using float conversion loses precision guarantees.</p>
|
|
3984
4666
|
|
|
3985
4667
|
</div>
|
|
@@ -4009,10 +4691,10 @@ Note: Using float conversion loses precision guarantees.</p>
|
|
|
4009
4691
|
<pre class="lines">
|
|
4010
4692
|
|
|
4011
4693
|
|
|
4012
|
-
|
|
4694
|
+
21</pre>
|
|
4013
4695
|
</td>
|
|
4014
4696
|
<td>
|
|
4015
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line
|
|
4697
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line 21</span>
|
|
4016
4698
|
|
|
4017
4699
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_f'>to_f</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span></pre>
|
|
4018
4700
|
</td>
|
|
@@ -4031,7 +4713,11 @@ Note: Using float conversion loses precision guarantees.</p>
|
|
|
4031
4713
|
|
|
4032
4714
|
</h3><div class="docstring">
|
|
4033
4715
|
<div class="discussion">
|
|
4034
|
-
<p
|
|
4716
|
+
<p class="note private">
|
|
4717
|
+
<strong>This method is part of a private API.</strong>
|
|
4718
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4719
|
+
</p>
|
|
4720
|
+
<p>Returns a Hash representation of the money instance.</p>
|
|
4035
4721
|
|
|
4036
4722
|
</div>
|
|
4037
4723
|
</div>
|
|
@@ -4069,12 +4755,12 @@ Note: Using float conversion loses precision guarantees.</p>
|
|
|
4069
4755
|
<pre class="lines">
|
|
4070
4756
|
|
|
4071
4757
|
|
|
4072
|
-
47
|
|
4073
4758
|
48
|
|
4074
|
-
49
|
|
4759
|
+
49
|
|
4760
|
+
50</pre>
|
|
4075
4761
|
</td>
|
|
4076
4762
|
<td>
|
|
4077
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line
|
|
4763
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line 48</span>
|
|
4078
4764
|
|
|
4079
4765
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_hash'>to_hash</span>
|
|
4080
4766
|
<span class='lbrace'>{</span> <span class='label'>currency:</span> <span class='id identifier rubyid_currency_code'>currency_code</span><span class='comma'>,</span> <span class='label'>amount:</span> <span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>%0.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_subunit'>subunit</span><span class='embexpr_end'>}</span><span class='tstring_content'>f</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|
@@ -4087,7 +4773,7 @@ Note: Using float conversion loses precision guarantees.</p>
|
|
|
4087
4773
|
<div class="method_details ">
|
|
4088
4774
|
<h3 class="signature " id="to_html-instance_method">
|
|
4089
4775
|
|
|
4090
|
-
#<strong>to_html</strong>(format = DEFAULT_FORMAT) ⇒ <tt>String</tt>
|
|
4776
|
+
#<strong>to_html</strong>(format = DEFAULT_FORMAT) ⇒ <tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>
|
|
4091
4777
|
|
|
4092
4778
|
|
|
4093
4779
|
|
|
@@ -4095,7 +4781,11 @@ Note: Using float conversion loses precision guarantees.</p>
|
|
|
4095
4781
|
|
|
4096
4782
|
</h3><div class="docstring">
|
|
4097
4783
|
<div class="discussion">
|
|
4098
|
-
<p
|
|
4784
|
+
<p class="note private">
|
|
4785
|
+
<strong>This method is part of a private API.</strong>
|
|
4786
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4787
|
+
</p>
|
|
4788
|
+
<p>Renders a safe HTML5 <code><data></code> element containing the formatted currency.
|
|
4099
4789
|
Embeds the ISO currency description and raw value as the metadata <code>title</code> attribute.</p>
|
|
4100
4790
|
|
|
4101
4791
|
</div>
|
|
@@ -4109,7 +4799,7 @@ Embeds the ISO currency description and raw value as the metadata <code>title</c
|
|
|
4109
4799
|
<span class='name'>format</span>
|
|
4110
4800
|
|
|
4111
4801
|
|
|
4112
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
4802
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
4113
4803
|
|
|
4114
4804
|
|
|
4115
4805
|
<em class="default">(defaults to: <tt>DEFAULT_FORMAT</tt>)</em>
|
|
@@ -4128,7 +4818,7 @@ Embeds the ISO currency description and raw value as the metadata <code>title</c
|
|
|
4128
4818
|
<li>
|
|
4129
4819
|
|
|
4130
4820
|
|
|
4131
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
4821
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
4132
4822
|
|
|
4133
4823
|
|
|
4134
4824
|
|
|
@@ -4145,18 +4835,18 @@ Embeds the ISO currency description and raw value as the metadata <code>title</c
|
|
|
4145
4835
|
<pre class="lines">
|
|
4146
4836
|
|
|
4147
4837
|
|
|
4148
|
-
27
|
|
4149
4838
|
28
|
|
4150
4839
|
29
|
|
4151
4840
|
30
|
|
4152
|
-
31
|
|
4841
|
+
31
|
|
4842
|
+
32</pre>
|
|
4153
4843
|
</td>
|
|
4154
4844
|
<td>
|
|
4155
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line
|
|
4845
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line 28</span>
|
|
4156
4846
|
|
|
4157
4847
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_html'>to_html</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#DEFAULT_FORMAT-constant" title="Mint::Money::DEFAULT_FORMAT (constant)">DEFAULT_FORMAT</a></span></span><span class='rparen'>)</span>
|
|
4158
4848
|
<span class='id identifier rubyid_title'>title</span> <span class='op'>=</span> <span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency_code'>currency_code</span><span class='embexpr_end'>}</span><span class='tstring_content'> %0.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_subunit'>subunit</span><span class='embexpr_end'>}</span><span class='tstring_content'>f</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span>
|
|
4159
|
-
<span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='id identifier
|
|
4849
|
+
<span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
|
|
4160
4850
|
<span class='tstring'><span class='tstring_beg'>%(</span><span class='tstring_content'><data class='money' title='</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_title'>title</span><span class='embexpr_end'>}</span><span class='tstring_content'>'></span><span class='embexpr_beg'>#{</span><span class='const'>ERB</span><span class='op'>::</span><span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_html_escape'>html_escape</span><span class='lparen'>(</span><span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'></data></span><span class='tstring_end'>)</span></span>
|
|
4161
4851
|
<span class='kw'>end</span></pre>
|
|
4162
4852
|
</td>
|
|
@@ -4175,7 +4865,11 @@ Embeds the ISO currency description and raw value as the metadata <code>title</c
|
|
|
4175
4865
|
|
|
4176
4866
|
</h3><div class="docstring">
|
|
4177
4867
|
<div class="discussion">
|
|
4178
|
-
<p
|
|
4868
|
+
<p class="note private">
|
|
4869
|
+
<strong>This method is part of a private API.</strong>
|
|
4870
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4871
|
+
</p>
|
|
4872
|
+
<p>Truncates and converts the monetary amount to an Integer.</p>
|
|
4179
4873
|
|
|
4180
4874
|
</div>
|
|
4181
4875
|
</div>
|
|
@@ -4213,10 +4907,10 @@ Embeds the ISO currency description and raw value as the metadata <code>title</c
|
|
|
4213
4907
|
<pre class="lines">
|
|
4214
4908
|
|
|
4215
4909
|
|
|
4216
|
-
|
|
4910
|
+
40</pre>
|
|
4217
4911
|
</td>
|
|
4218
4912
|
<td>
|
|
4219
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line
|
|
4913
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line 40</span>
|
|
4220
4914
|
|
|
4221
4915
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span></pre>
|
|
4222
4916
|
</td>
|
|
@@ -4227,7 +4921,7 @@ Embeds the ISO currency description and raw value as the metadata <code>title</c
|
|
|
4227
4921
|
<div class="method_details ">
|
|
4228
4922
|
<h3 class="signature " id="to_json-instance_method">
|
|
4229
4923
|
|
|
4230
|
-
#<strong>to_json</strong>(*_args) ⇒ <tt>String</tt>
|
|
4924
|
+
#<strong>to_json</strong>(*_args) ⇒ <tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>
|
|
4231
4925
|
|
|
4232
4926
|
|
|
4233
4927
|
|
|
@@ -4235,7 +4929,11 @@ Embeds the ISO currency description and raw value as the metadata <code>title</c
|
|
|
4235
4929
|
|
|
4236
4930
|
</h3><div class="docstring">
|
|
4237
4931
|
<div class="discussion">
|
|
4238
|
-
<p
|
|
4932
|
+
<p class="note private">
|
|
4933
|
+
<strong>This method is part of a private API.</strong>
|
|
4934
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4935
|
+
</p>
|
|
4936
|
+
<p>Serializes the money instance to a standard JSON object containing the amount and currency.
|
|
4239
4937
|
Highly optimized to run without external dependencies.</p>
|
|
4240
4938
|
|
|
4241
4939
|
</div>
|
|
@@ -4248,7 +4946,7 @@ Highly optimized to run without external dependencies.</p>
|
|
|
4248
4946
|
<li>
|
|
4249
4947
|
|
|
4250
4948
|
|
|
4251
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
4949
|
+
<span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
|
|
4252
4950
|
|
|
4253
4951
|
|
|
4254
4952
|
|
|
@@ -4265,14 +4963,14 @@ Highly optimized to run without external dependencies.</p>
|
|
|
4265
4963
|
<pre class="lines">
|
|
4266
4964
|
|
|
4267
4965
|
|
|
4268
|
-
55
|
|
4269
4966
|
56
|
|
4270
4967
|
57
|
|
4271
4968
|
58
|
|
4272
|
-
59
|
|
4969
|
+
59
|
|
4970
|
+
60</pre>
|
|
4273
4971
|
</td>
|
|
4274
4972
|
<td>
|
|
4275
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line
|
|
4973
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line 56</span>
|
|
4276
4974
|
|
|
4277
4975
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_json'>to_json</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid__args'>_args</span><span class='rparen'>)</span>
|
|
4278
4976
|
<span class='const'>Kernel</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span><span class='lparen'>(</span>
|
|
@@ -4295,7 +4993,11 @@ Highly optimized to run without external dependencies.</p>
|
|
|
4295
4993
|
|
|
4296
4994
|
</h3><div class="docstring">
|
|
4297
4995
|
<div class="discussion">
|
|
4298
|
-
<p
|
|
4996
|
+
<p class="note private">
|
|
4997
|
+
<strong>This method is part of a private API.</strong>
|
|
4998
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
4999
|
+
</p>
|
|
5000
|
+
<p>Returns the exact internal Rational representation of the monetary amount.</p>
|
|
4299
5001
|
|
|
4300
5002
|
</div>
|
|
4301
5003
|
</div>
|
|
@@ -4324,10 +5026,10 @@ Highly optimized to run without external dependencies.</p>
|
|
|
4324
5026
|
<pre class="lines">
|
|
4325
5027
|
|
|
4326
5028
|
|
|
4327
|
-
|
|
5029
|
+
65</pre>
|
|
4328
5030
|
</td>
|
|
4329
5031
|
<td>
|
|
4330
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line
|
|
5032
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/conversion.rb', line 65</span>
|
|
4331
5033
|
|
|
4332
5034
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_r'>to_r</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span></pre>
|
|
4333
5035
|
</td>
|
|
@@ -4338,203 +5040,29 @@ Highly optimized to run without external dependencies.</p>
|
|
|
4338
5040
|
<div class="method_details ">
|
|
4339
5041
|
<h3 class="signature " id="to_s-instance_method">
|
|
4340
5042
|
|
|
4341
|
-
#<strong>to_s</strong>
|
|
4342
|
-
|
|
4343
|
-
|
|
5043
|
+
#<strong>to_s</strong> ⇒ <tt>Object</tt>
|
|
4344
5044
|
|
|
4345
5045
|
|
|
4346
5046
|
|
|
4347
|
-
</h3><div class="docstring">
|
|
4348
|
-
<div class="discussion">
|
|
4349
|
-
<p>Formats money as a string with customizable format, thousand delimiter, and decimal</p>
|
|
4350
|
-
|
|
4351
|
-
</div>
|
|
4352
|
-
</div>
|
|
4353
|
-
<div class="tags">
|
|
4354
|
-
|
|
4355
|
-
<div class="examples">
|
|
4356
|
-
<h4 class="tag_title">Examples:</h4>
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
<h5 class="example_title"><div class='inline'><p>Basic formatting</p></div></h5>
|
|
4360
|
-
|
|
4361
|
-
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='float'>1234.56</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>USD</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
4362
|
-
<span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='comment'>#=> "$1,234.56"
|
|
4363
|
-
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>thousand:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>decimal:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$1.234,56"
|
|
4364
|
-
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>decimal:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>thousand:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$1234,56"</span></code></pre>
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
<h5 class="example_title"><div class='inline'><p>Custom formats</p></div></h5>
|
|
4368
|
-
|
|
4369
|
-
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "1234.56"
|
|
4370
|
-
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<currency>s %<amount>f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "USD 1234.56"
|
|
4371
|
-
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>f %<symbol>s</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "1234.56 $"
|
|
4372
|
-
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<symbol>s%<amount>+f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$+1234.56"</span></code></pre>
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
<h5 class="example_title"><div class='inline'><p>Integral & fractional parts</p></div></h5>
|
|
4376
|
-
|
|
4377
|
-
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<integral>d.%<fractional>02d</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "1234.56"
|
|
4378
|
-
</span><span class='id identifier rubyid_price'>price</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='float'>0.99</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>USD</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
4379
|
-
<span class='id identifier rubyid_price'>price</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<integral>d dollars and %<fractional>02d cents</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
4380
|
-
<span class='comment'>#=> "0 dollars and 99 cents"</span></code></pre>
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
<h5 class="example_title"><div class='inline'><p>Per-sign Hash format (accounting parentheses)</p></div></h5>
|
|
4384
|
-
|
|
4385
|
-
<pre class="example code"><code><span class='id identifier rubyid_loss'>loss</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='op'>-</span><span class='float'>1234.56</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>USD</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
4386
|
-
<span class='id identifier rubyid_loss'>loss</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>negative:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>(%<symbol>s%<amount>f)</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>#=> "($1,234.56)"
|
|
4387
|
-
</span><span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_money'><span class='object_link'><a href="../Mint.html#money-class_method" title="Mint.money (method)">money</a></span></span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>BRL</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>zero:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>--</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span> <span class='comment'>#=> "--"</span></code></pre>
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
<h5 class="example_title"><div class='inline'><p>Padding and alignment</p></div></h5>
|
|
4391
|
-
|
|
4392
|
-
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<amount>10.2f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> " 1234.56"
|
|
4393
|
-
</span><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>%<symbol>s%<amount>010.2f</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='comment'>#=> "$0001234.56"</span></code></pre>
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
<h5 class="example_title"><div class='inline'><p>Locale-aware formatting (with Mint.locale_backend set)</p></div></h5>
|
|
4397
|
-
|
|
4398
|
-
<pre class="example code"><code><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='comment'># decimal and thousand come from locale_backend</span></code></pre>
|
|
4399
|
-
|
|
4400
|
-
</div>
|
|
4401
|
-
<p class="tag_title">Parameters:</p>
|
|
4402
|
-
<ul class="param">
|
|
4403
|
-
|
|
4404
|
-
<li>
|
|
4405
|
-
|
|
4406
|
-
<span class='name'>format</span>
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
<span class='type'>(<tt>String</tt>, <tt>Hash</tt>, <tt>nil</tt>)</span>
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
—
|
|
4416
|
-
<div class='inline'><p>Either a Format string with placeholders
|
|
4417
|
-
(%<symbol>s, %<amount>f, %<currency>s, %<integral>d, %<fractional>d),
|
|
4418
|
-
or a Hash with per-sign keys (:positive, :negative, :zero) each
|
|
4419
|
-
holding a format string. A Hash is convenient for sign-aware formats
|
|
4420
|
-
such as accounting parentheses:</p>
|
|
4421
|
-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_money'>money</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</span><span class='label'>format:</span> <span class='lbrace'>{</span> <span class='label'>negative:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>(%<symbol>s%<amount>f)</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
4422
|
-
</code></pre>
|
|
4423
|
-
<p>Missing keys fall back to the module default, so a Hash with only
|
|
4424
|
-
:negative will still format positives sensibly. The valid keys are
|
|
4425
|
-
:positive, :negative, :zero; anything else raises ArgumentError.
|
|
4426
|
-
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise
|
|
4427
|
-
<code>"%<symbol>s%<amount>f"</code>.</p></div>
|
|
4428
|
-
|
|
4429
|
-
</li>
|
|
4430
|
-
|
|
4431
|
-
<li>
|
|
4432
|
-
|
|
4433
|
-
<span class='name'>thousand</span>
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
<span class='type'>(<tt>String</tt>, <tt>false</tt>, <tt>nil</tt>)</span>
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
—
|
|
4443
|
-
<div class='inline'><p>Thousands delimiter (e.g., ',' for 1,000).
|
|
4444
|
-
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise <code>","</code>.</p></div>
|
|
4445
|
-
|
|
4446
|
-
</li>
|
|
4447
|
-
|
|
4448
|
-
<li>
|
|
4449
|
-
|
|
4450
|
-
<span class='name'>decimal</span>
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
<span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
—
|
|
4460
|
-
<div class='inline'><p>Decimal separator (e.g., '.' or ',').
|
|
4461
|
-
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise <code>"."</code>.</p></div>
|
|
4462
|
-
|
|
4463
|
-
</li>
|
|
4464
|
-
|
|
4465
|
-
</ul>
|
|
4466
5047
|
|
|
4467
|
-
<p class="tag_title">Returns:</p>
|
|
4468
|
-
<ul class="return">
|
|
4469
|
-
|
|
4470
|
-
<li>
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
—
|
|
4478
|
-
<div class='inline'><p>Formatted money string</p></div>
|
|
4479
|
-
|
|
4480
|
-
</li>
|
|
4481
5048
|
|
|
4482
|
-
</
|
|
4483
|
-
<p class="tag_title">Raises:</p>
|
|
4484
|
-
<ul class="raise">
|
|
4485
|
-
|
|
4486
|
-
<li>
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
—
|
|
4494
|
-
<div class='inline'><p>if <code>format</code> is not a String or Hash, the Hash
|
|
4495
|
-
is empty, or the Hash contains an unrecognised key.</p></div>
|
|
4496
|
-
|
|
4497
|
-
</li>
|
|
4498
|
-
|
|
4499
|
-
</ul>
|
|
4500
|
-
|
|
4501
|
-
</div><table class="source_code">
|
|
5049
|
+
</h3><table class="source_code">
|
|
4502
5050
|
<tr>
|
|
4503
5051
|
<td>
|
|
4504
5052
|
<pre class="lines">
|
|
4505
5053
|
|
|
4506
5054
|
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
64
|
|
4512
|
-
65
|
|
4513
|
-
66
|
|
4514
|
-
67
|
|
4515
|
-
68
|
|
4516
|
-
69
|
|
4517
|
-
70
|
|
4518
|
-
71
|
|
4519
|
-
72
|
|
4520
|
-
73</pre>
|
|
5055
|
+
110
|
|
5056
|
+
111
|
|
5057
|
+
112
|
|
5058
|
+
113</pre>
|
|
4521
5059
|
</td>
|
|
4522
5060
|
<td>
|
|
4523
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/format/to_s.rb', line
|
|
5061
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/format/to_s.rb', line 110</span>
|
|
4524
5062
|
|
|
4525
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span
|
|
4526
|
-
<span class='
|
|
4527
|
-
|
|
4528
|
-
<span class='kw'>case</span> <span class='id identifier rubyid_format'>format</span>
|
|
4529
|
-
<span class='kw'>when</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span> <span class='kw'>then</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'>format must not be empty</span><span class='tstring_end'>'</span></span>
|
|
4530
|
-
<span class='kw'>when</span> <span class='const'>Hash</span> <span class='kw'>then</span> <span class='id identifier rubyid_validate_format_hash'>validate_format_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='rparen'>)</span>
|
|
4531
|
-
<span class='kw'>when</span> <span class='const'>String</span> <span class='kw'>then</span> <span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>positive:</span> <span class='id identifier rubyid_format'>format</span> <span class='rbrace'>}</span>
|
|
4532
|
-
<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'>Invalid format. Only String or Hash are accepted</span><span class='tstring_end'>'</span></span>
|
|
4533
|
-
<span class='kw'>end</span>
|
|
4534
|
-
|
|
4535
|
-
<span class='id identifier rubyid_formatted'>formatted</span> <span class='op'>=</span> <span class='id identifier rubyid_format_amount'>format_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_format'>format</span><span class='comma'>,</span> <span class='label'>decimal:</span> <span class='id identifier rubyid_decimal'>decimal</span><span class='comma'>,</span> <span class='label'>thousand:</span> <span class='id identifier rubyid_thousand'>thousand</span><span class='rparen'>)</span>
|
|
4536
|
-
|
|
4537
|
-
<span class='id identifier rubyid_width'>width</span> <span class='op'>?</span> <span class='id identifier rubyid_formatted'>formatted</span><span class='period'>.</span><span class='id identifier rubyid_rjust'>rjust</span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_formatted'>formatted</span>
|
|
5063
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
|
5064
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_format'>format</span> <span class='kw'>unless</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_locale_backend'><span class='object_link'><a href="../Mint.html#locale_backend-class_method" title="Mint.locale_backend (method)">locale_backend</a></span></span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
|
5065
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_symbol'>symbol</span><span class='embexpr_end'>}</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_amount_to_s'>amount_to_s</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
|
4538
5066
|
<span class='kw'>end</span></pre>
|
|
4539
5067
|
</td>
|
|
4540
5068
|
</tr>
|
|
@@ -4552,7 +5080,11 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
4552
5080
|
|
|
4553
5081
|
</h3><div class="docstring">
|
|
4554
5082
|
<div class="discussion">
|
|
4555
|
-
<p
|
|
5083
|
+
<p class="note private">
|
|
5084
|
+
<strong>This method is part of a private API.</strong>
|
|
5085
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
5086
|
+
</p>
|
|
5087
|
+
<p>Returns true if amount is zero.</p>
|
|
4556
5088
|
|
|
4557
5089
|
</div>
|
|
4558
5090
|
</div>
|
|
@@ -4597,7 +5129,7 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
4597
5129
|
</div>
|
|
4598
5130
|
|
|
4599
5131
|
<div id="footer">
|
|
4600
|
-
Generated on
|
|
5132
|
+
Generated on Wed Jul 1 01:11:53 2026 by
|
|
4601
5133
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
4602
5134
|
0.9.44 (ruby-4.0.5).
|
|
4603
5135
|
</div>
|