minting 1.7.0 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +80 -112
- data/Rakefile +13 -1
- data/bin/bench_check +46 -0
- data/doc/Mint/Currency.html +446 -46
- data/doc/Mint/CurrencyRegistry.html +7 -7
- data/doc/Mint/Money.html +203 -177
- data/doc/Mint/RangeStepPatch.html +277 -0
- data/doc/Mint/Registry.html +842 -0
- data/doc/Mint/UnknownCurrency.html +2 -2
- data/doc/Mint.html +385 -66
- data/doc/Minting.html +3 -3
- data/doc/_index.html +24 -9
- data/doc/agents/api_review-2026-06-15.md +342 -0
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +97 -89
- data/doc/index.html +97 -89
- data/doc/method_list.html +97 -25
- data/doc/top-level-namespace.html +13 -5
- data/lib/minting/currency/currency.rb +75 -0
- data/lib/minting/mint/aliases.rb +3 -0
- data/lib/minting/mint/dsl/{refinements.rb → numeric.rb} +6 -5
- data/lib/minting/mint/dsl/range.rb +31 -18
- data/lib/minting/mint/dsl/string.rb +12 -0
- data/lib/minting/mint/dsl/top_level.rb +3 -0
- data/lib/minting/mint/locale_backend.rb +29 -0
- data/lib/minting/mint/mint.rb +28 -12
- data/lib/minting/mint/parser/parser.rb +62 -0
- data/lib/minting/mint/parser/separators.rb +39 -0
- data/lib/minting/mint/registry/registration.rb +33 -0
- data/lib/minting/mint/registry/registry.rb +38 -0
- data/lib/minting/mint/registry/symbols.rb +49 -0
- data/lib/minting/mint/registry/zeros.rb +18 -0
- data/lib/minting/mint.rb +13 -16
- data/lib/minting/money/allocation/allocation.rb +25 -0
- data/lib/minting/money/{allocation.rb → allocation/split.rb} +1 -19
- data/lib/minting/money/arithmetics/methods.rb +27 -0
- data/lib/minting/money/{arithmetics.rb → arithmetics/operators.rb} +0 -21
- data/lib/minting/money/clamp.rb +66 -0
- data/lib/minting/money/coercion.rb +10 -0
- data/lib/minting/money/comparable.rb +6 -0
- data/lib/minting/money/constructors.rb +14 -9
- data/lib/minting/money/format/formatting.rb +60 -0
- data/lib/minting/money/{formatting.rb → format/to_s.rb} +13 -36
- data/lib/minting/money/money.rb +12 -58
- data/lib/minting/version.rb +1 -1
- metadata +29 -19
- data/lib/minting/mint/currency/currency.rb +0 -36
- data/lib/minting/mint/currency/currency_registry.rb +0 -67
- data/lib/minting/mint/currency/world_currencies.rb +0 -16
- data/lib/minting/mint/parser.rb +0 -85
- /data/doc/agents/{AGENTS.md → expired/AGENTS.md} +0 -0
- /data/doc/agents/{copilot-instructions.md → expired/copilot-instructions.md} +0 -0
- /data/doc/agents/{gemini_gem_evaluation.md → expired/gemini_gem_evaluation.md} +0 -0
- /data/doc/agents/{recommendations.md → expired/recommendations.md} +0 -0
- /data/doc/agents/{rubocop-issues.md → expired/rubocop-issues.md} +0 -0
data/doc/Mint/Money.html
CHANGED
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
|
|
102
102
|
<dl>
|
|
103
103
|
<dt>Defined in:</dt>
|
|
104
|
-
<dd>lib/minting/money/
|
|
105
|
-
lib/minting/money/
|
|
104
|
+
<dd>lib/minting/money/clamp.rb<span class="defines">,<br>
|
|
105
|
+
lib/minting/money/money.rb,<br> lib/minting/money/coercion.rb,<br> lib/minting/money/comparable.rb,<br> lib/minting/money/conversion.rb,<br> lib/minting/money/format/to_s.rb,<br> lib/minting/money/constructors.rb,<br> lib/minting/money/allocation/split.rb,<br> lib/minting/money/format/formatting.rb,<br> lib/minting/money/arithmetics/methods.rb,<br> lib/minting/money/allocation/allocation.rb,<br> lib/minting/money/arithmetics/operators.rb</span>
|
|
106
106
|
|
|
107
107
|
</dd>
|
|
108
108
|
</dl>
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
|
|
112
112
|
<h2>Overview</h2><div class="docstring">
|
|
113
113
|
<div class="discussion">
|
|
114
|
-
<p>Money
|
|
114
|
+
<p>Money Arithmetics</p>
|
|
115
115
|
|
|
116
116
|
</div>
|
|
117
117
|
</div>
|
|
@@ -528,7 +528,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
528
528
|
|
|
529
529
|
|
|
530
530
|
|
|
531
|
-
|
|
531
|
+
<span class="private note title">private</span>
|
|
532
532
|
|
|
533
533
|
|
|
534
534
|
<span class="summary_desc"><div class='inline'><p>Allows <span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span> to interact seamlessly as the right-hand operand in Numeric arithmetic.</p></div></span>
|
|
@@ -575,7 +575,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
575
575
|
|
|
576
576
|
|
|
577
577
|
|
|
578
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
|
578
|
+
<span class="summary_desc"><div class='inline'><p>Strict equality — both amount and currency must match exactly.</p></div></span>
|
|
579
579
|
|
|
580
580
|
</li>
|
|
581
581
|
|
|
@@ -693,7 +693,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
693
693
|
<li class="public ">
|
|
694
694
|
<span class="summary_signature">
|
|
695
695
|
|
|
696
|
-
<a href="#nonzero%3F-instance_method" title="#nonzero? (instance method)">#<strong>nonzero?</strong> ⇒
|
|
696
|
+
<a href="#nonzero%3F-instance_method" title="#nonzero? (instance method)">#<strong>nonzero?</strong> ⇒ self<sup>?</sup> </a>
|
|
697
697
|
|
|
698
698
|
|
|
699
699
|
|
|
@@ -707,7 +707,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
707
707
|
|
|
708
708
|
|
|
709
709
|
|
|
710
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
|
710
|
+
<span class="summary_desc"><div class='inline'><p>Self if amount is non-zero, nil otherwise.</p></div></span>
|
|
711
711
|
|
|
712
712
|
</li>
|
|
713
713
|
|
|
@@ -759,7 +759,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
759
759
|
<li class="public ">
|
|
760
760
|
<span class="summary_signature">
|
|
761
761
|
|
|
762
|
-
<a href="#split-instance_method" title="#split (instance method)">#<strong>split</strong>(
|
|
762
|
+
<a href="#split-instance_method" title="#split (instance method)">#<strong>split</strong>(slices) ⇒ Array<Money> </a>
|
|
763
763
|
|
|
764
764
|
|
|
765
765
|
|
|
@@ -957,7 +957,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
957
957
|
<li class="public ">
|
|
958
958
|
<span class="summary_signature">
|
|
959
959
|
|
|
960
|
-
<a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong>(format:
|
|
960
|
+
<a href="#to_s-instance_method" title="#to_s (instance method)">#<strong>to_s</strong>(format: nil, decimal: nil, thousand: nil, width: nil) ⇒ String </a>
|
|
961
961
|
|
|
962
962
|
|
|
963
963
|
|
|
@@ -993,7 +993,7 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
993
993
|
|
|
994
994
|
|
|
995
995
|
|
|
996
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
|
996
|
+
<span class="summary_desc"><div class='inline'><p>True if amount is zero.</p></div></span>
|
|
997
997
|
|
|
998
998
|
</li>
|
|
999
999
|
|
|
@@ -1033,12 +1033,12 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1033
1033
|
<pre class="lines">
|
|
1034
1034
|
|
|
1035
1035
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1036
|
+
22
|
|
1037
|
+
23
|
|
1038
|
+
24</pre>
|
|
1039
1039
|
</td>
|
|
1040
1040
|
<td>
|
|
1041
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
1041
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 22</span>
|
|
1042
1042
|
|
|
1043
1043
|
<span class='kw'>def</span> <span class='id identifier rubyid_amount'>amount</span>
|
|
1044
1044
|
<span class='ivar'>@amount</span>
|
|
@@ -1074,12 +1074,12 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1074
1074
|
<pre class="lines">
|
|
1075
1075
|
|
|
1076
1076
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1077
|
+
22
|
|
1078
|
+
23
|
|
1079
|
+
24</pre>
|
|
1080
1080
|
</td>
|
|
1081
1081
|
<td>
|
|
1082
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
1082
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 22</span>
|
|
1083
1083
|
|
|
1084
1084
|
<span class='kw'>def</span> <span class='id identifier rubyid_currency'>currency</span>
|
|
1085
1085
|
<span class='ivar'>@currency</span>
|
|
@@ -1183,10 +1183,10 @@ Uses <code>%<symbol>s</code> for the currency symbol and <code>%<amount
|
|
|
1183
1183
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</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>
|
|
1184
1184
|
<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>
|
|
1185
1185
|
|
|
1186
|
-
<span class='id identifier
|
|
1187
|
-
<span class='id identifier
|
|
1186
|
+
<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>
|
|
1187
|
+
<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>
|
|
1188
1188
|
|
|
1189
|
-
<span class='id identifier
|
|
1189
|
+
<span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</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_zero'><span class='object_link'><a href="../Mint.html#zero-class_method" title="Mint.zero (method)">zero</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new'>new</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>
|
|
1190
1190
|
<span class='kw'>end</span></pre>
|
|
1191
1191
|
</td>
|
|
1192
1192
|
</tr>
|
|
@@ -1312,9 +1312,7 @@ is not registered</p></div>
|
|
|
1312
1312
|
40
|
|
1313
1313
|
41
|
|
1314
1314
|
42
|
|
1315
|
-
43
|
|
1316
|
-
44
|
|
1317
|
-
45</pre>
|
|
1315
|
+
43</pre>
|
|
1318
1316
|
</td>
|
|
1319
1317
|
<td>
|
|
1320
1318
|
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 37</span>
|
|
@@ -1322,11 +1320,9 @@ is not registered</p></div>
|
|
|
1322
1320
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_from_fractional'>from_fractional</span><span class='lparen'>(</span><span class='id identifier rubyid_fractional'>fractional</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
1323
1321
|
<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'>fractional must be an Integer</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_fractional'>fractional</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>
|
|
1324
1322
|
|
|
1325
|
-
<span class='id identifier
|
|
1326
|
-
<span class='id identifier
|
|
1327
|
-
|
|
1328
|
-
<span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='const'>Rational</span><span class='lparen'>(</span><span class='id identifier rubyid_fractional'>fractional</span><span class='comma'>,</span> <span class='id identifier rubyid_checked_currency'>checked_currency</span><span class='period'>.</span><span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span><span class='rparen'>)</span>
|
|
1329
|
-
<span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_checked_currency'>checked_currency</span><span class='rparen'>)</span>
|
|
1323
|
+
<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>
|
|
1324
|
+
<span class='id identifier rubyid_amount'>amount</span> <span class='op'>=</span> <span class='const'>Rational</span><span class='lparen'>(</span><span class='id identifier rubyid_fractional'>fractional</span><span class='comma'>,</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>
|
|
1325
|
+
<span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</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_zero'><span class='object_link'><a href="../Mint.html#zero-class_method" title="Mint.zero (method)">zero</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_new'>new</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>
|
|
1330
1326
|
<span class='kw'>end</span></pre>
|
|
1331
1327
|
</td>
|
|
1332
1328
|
</tr>
|
|
@@ -1413,19 +1409,19 @@ is not registered</p></div>
|
|
|
1413
1409
|
<pre class="lines">
|
|
1414
1410
|
|
|
1415
1411
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1412
|
+
42
|
|
1413
|
+
43
|
|
1414
|
+
44
|
|
1415
|
+
45
|
|
1416
|
+
46</pre>
|
|
1421
1417
|
</td>
|
|
1422
1418
|
<td>
|
|
1423
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line
|
|
1419
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 42</span>
|
|
1424
1420
|
|
|
1425
1421
|
<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>
|
|
1426
|
-
<span class='
|
|
1422
|
+
<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>
|
|
1427
1423
|
|
|
1428
|
-
<span class='id identifier
|
|
1424
|
+
<span class='id identifier rubyid_mint'>mint</span><span class='lparen'>(</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>
|
|
1429
1425
|
<span class='kw'>end</span></pre>
|
|
1430
1426
|
</td>
|
|
1431
1427
|
</tr>
|
|
@@ -1503,14 +1499,14 @@ is not registered</p></div>
|
|
|
1503
1499
|
<pre class="lines">
|
|
1504
1500
|
|
|
1505
1501
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1502
|
+
67
|
|
1503
|
+
68
|
|
1504
|
+
69
|
|
1505
|
+
70
|
|
1506
|
+
71</pre>
|
|
1511
1507
|
</td>
|
|
1512
1508
|
<td>
|
|
1513
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line
|
|
1509
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 67</span>
|
|
1514
1510
|
|
|
1515
1511
|
<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>
|
|
1516
1512
|
<span class='kw'>return</span> <span class='id identifier rubyid_mint'>mint</span><span class='lparen'>(</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>
|
|
@@ -1596,23 +1592,23 @@ is not registered</p></div>
|
|
|
1596
1592
|
<pre class="lines">
|
|
1597
1593
|
|
|
1598
1594
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1595
|
+
11
|
|
1596
|
+
12
|
|
1597
|
+
13
|
|
1598
|
+
14
|
|
1599
|
+
15
|
|
1600
|
+
16
|
|
1601
|
+
17</pre>
|
|
1606
1602
|
</td>
|
|
1607
1603
|
<td>
|
|
1608
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line
|
|
1604
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 11</span>
|
|
1609
1605
|
|
|
1610
1606
|
<span class='kw'>def</span> <span class='op'>+</span><span class='lparen'>(</span><span class='id identifier rubyid_addend'>addend</span><span class='rparen'>)</span>
|
|
1611
1607
|
<span class='kw'>case</span> <span class='id identifier rubyid_addend'>addend</span>
|
|
1612
|
-
<span class='kw'>
|
|
1613
|
-
<span class='kw'>
|
|
1608
|
+
<span class='kw'>in</span> <span class='int'>0</span> <span class='kw'>then</span> <span class='kw'>self</span>
|
|
1609
|
+
<span class='kw'>in</span> <span class='const'><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></span> <span class='kw'>if</span> <span class='id identifier rubyid_same_currency?'>same_currency?</span><span class='lparen'>(</span><span class='id identifier rubyid_addend'>addend</span><span class='rparen'>)</span> <span class='kw'>then</span> <span class='id identifier rubyid_mint'>mint</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span> <span class='op'>+</span> <span class='id identifier rubyid_addend'>addend</span><span class='period'>.</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span>
|
|
1610
|
+
<span class='kw'>else</span> <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='id identifier rubyid_addend'>addend</span><span class='embexpr_end'>}</span><span class='tstring_content'> can't be added to </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
|
1614
1611
|
<span class='kw'>end</span>
|
|
1615
|
-
<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='id identifier rubyid_addend'>addend</span><span class='embexpr_end'>}</span><span class='tstring_content'> can't be added to </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
|
1616
1612
|
<span class='kw'>end</span></pre>
|
|
1617
1613
|
</td>
|
|
1618
1614
|
</tr>
|
|
@@ -1693,16 +1689,16 @@ is not registered</p></div>
|
|
|
1693
1689
|
<pre class="lines">
|
|
1694
1690
|
|
|
1695
1691
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1692
|
+
24
|
|
1693
|
+
25
|
|
1694
|
+
26
|
|
1695
|
+
27
|
|
1696
|
+
28
|
|
1697
|
+
29
|
|
1698
|
+
30</pre>
|
|
1703
1699
|
</td>
|
|
1704
1700
|
<td>
|
|
1705
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line
|
|
1701
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 24</span>
|
|
1706
1702
|
|
|
1707
1703
|
<span class='kw'>def</span> <span class='op'>-</span><span class='lparen'>(</span><span class='id identifier rubyid_subtrahend'>subtrahend</span><span class='rparen'>)</span>
|
|
1708
1704
|
<span class='kw'>case</span> <span class='id identifier rubyid_subtrahend'>subtrahend</span>
|
|
@@ -1756,10 +1752,10 @@ is not registered</p></div>
|
|
|
1756
1752
|
<pre class="lines">
|
|
1757
1753
|
|
|
1758
1754
|
|
|
1759
|
-
|
|
1755
|
+
35</pre>
|
|
1760
1756
|
</td>
|
|
1761
1757
|
<td>
|
|
1762
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line
|
|
1758
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 35</span>
|
|
1763
1759
|
|
|
1764
1760
|
<span class='kw'>def</span> <span class='op'>-@</span> <span class='op'>=</span> <span class='id identifier rubyid_mint'>mint</span><span class='lparen'>(</span><span class='op'>-</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span></pre>
|
|
1765
1761
|
</td>
|
|
@@ -1853,16 +1849,16 @@ is not registered</p></div>
|
|
|
1853
1849
|
<pre class="lines">
|
|
1854
1850
|
|
|
1855
1851
|
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1852
|
+
54
|
|
1853
|
+
55
|
|
1854
|
+
56
|
|
1855
|
+
57
|
|
1856
|
+
58
|
|
1857
|
+
59
|
|
1858
|
+
60</pre>
|
|
1863
1859
|
</td>
|
|
1864
1860
|
<td>
|
|
1865
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line
|
|
1861
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/operators.rb', line 54</span>
|
|
1866
1862
|
|
|
1867
1863
|
<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>
|
|
1868
1864
|
<span class='kw'>case</span> <span class='id identifier rubyid_divisor'>divisor</span>
|
|
@@ -1914,16 +1910,16 @@ two_usd > Mint.money(2, 'BRL')
|
|
|
1914
1910
|
<pre class="lines">
|
|
1915
1911
|
|
|
1916
1912
|
|
|
1917
|
-
32
|
|
1918
|
-
33
|
|
1919
|
-
34
|
|
1920
|
-
35
|
|
1921
1913
|
36
|
|
1922
1914
|
37
|
|
1923
|
-
38
|
|
1915
|
+
38
|
|
1916
|
+
39
|
|
1917
|
+
40
|
|
1918
|
+
41
|
|
1919
|
+
42</pre>
|
|
1924
1920
|
</td>
|
|
1925
1921
|
<td>
|
|
1926
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line
|
|
1922
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line 36</span>
|
|
1927
1923
|
|
|
1928
1924
|
<span class='kw'>def</span> <span class='op'><=></span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span>
|
|
1929
1925
|
<span class='kw'>case</span> <span class='id identifier rubyid_other'>other</span>
|
|
@@ -2043,7 +2039,7 @@ two_usd > Mint.money(2, 'BRL')
|
|
|
2043
2039
|
9</pre>
|
|
2044
2040
|
</td>
|
|
2045
2041
|
<td>
|
|
2046
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line 9</span>
|
|
2042
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/methods.rb', line 9</span>
|
|
2047
2043
|
|
|
2048
2044
|
<span class='kw'>def</span> <span class='id identifier rubyid_abs'>abs</span> <span class='op'>=</span> <span class='id identifier rubyid_mint'>mint</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='rparen'>)</span></pre>
|
|
2049
2045
|
</td>
|
|
@@ -2148,7 +2144,7 @@ Disperses any subunit rounding amounts across the initial slots</p>
|
|
|
2148
2144
|
23</pre>
|
|
2149
2145
|
</td>
|
|
2150
2146
|
<td>
|
|
2151
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/allocation.rb', line 15</span>
|
|
2147
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/allocation/allocation.rb', line 15</span>
|
|
2152
2148
|
|
|
2153
2149
|
<span class='kw'>def</span> <span class='id identifier rubyid_allocate'>allocate</span><span class='lparen'>(</span><span class='id identifier rubyid_proportions'>proportions</span><span class='rparen'>)</span>
|
|
2154
2150
|
<span class='id identifier rubyid_whole'>whole</span> <span class='op'>=</span> <span class='id identifier rubyid_proportions'>proportions</span><span class='period'>.</span><span class='id identifier rubyid_sum'>sum</span><span class='period'>.</span><span class='id identifier rubyid_to_r'>to_r</span>
|
|
@@ -2157,7 +2153,7 @@ Disperses any subunit rounding amounts across the initial slots</p>
|
|
|
2157
2153
|
|
|
2158
2154
|
<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>
|
|
2159
2155
|
<span class='id identifier rubyid_amounts'>amounts</span> <span class='op'>=</span> <span class='id identifier rubyid_proportions'>proportions</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_rate'>rate</span><span class='op'>|</span> <span class='const'>Rational</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span> <span class='op'>*</span> <span class='id identifier rubyid_rate'>rate</span><span class='comma'>,</span> <span class='id identifier rubyid_whole'>whole</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='id identifier rubyid_subunit'>subunit</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|
2160
|
-
<span class='id identifier rubyid_allocate_left_over
|
|
2156
|
+
<span class='id identifier rubyid_allocate_left_over'>allocate_left_over</span><span class='lparen'>(</span><span class='label'>amounts:</span> <span class='id identifier rubyid_amounts'>amounts</span><span class='comma'>,</span> <span class='label'>left_over:</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>-</span> <span class='id identifier rubyid_amounts'>amounts</span><span class='period'>.</span><span class='id identifier rubyid_sum'>sum</span><span class='rparen'>)</span>
|
|
2161
2157
|
<span class='kw'>end</span></pre>
|
|
2162
2158
|
</td>
|
|
2163
2159
|
</tr>
|
|
@@ -2296,19 +2292,19 @@ if min is a Range, and max is not nil</p></div>
|
|
|
2296
2292
|
<pre class="lines">
|
|
2297
2293
|
|
|
2298
2294
|
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2295
|
+
42
|
|
2296
|
+
43
|
|
2297
|
+
44
|
|
2298
|
+
45
|
|
2299
|
+
46
|
|
2300
|
+
47
|
|
2301
|
+
48
|
|
2302
|
+
49
|
|
2303
|
+
50
|
|
2304
|
+
51</pre>
|
|
2309
2305
|
</td>
|
|
2310
2306
|
<td>
|
|
2311
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/
|
|
2307
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/clamp.rb', line 42</span>
|
|
2312
2308
|
|
|
2313
2309
|
<span class='kw'>def</span> <span class='id identifier rubyid_clamp'>clamp</span><span class='lparen'>(</span><span class='id identifier rubyid_min_or_range'>min_or_range</span><span class='comma'>,</span> <span class='id identifier rubyid_max'>max</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
2314
2310
|
<span class='kw'>if</span> <span class='id identifier rubyid_min_or_range'>min_or_range</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Range</span><span class='rparen'>)</span>
|
|
@@ -2336,8 +2332,12 @@ if min is a Range, and max is not nil</p></div>
|
|
|
2336
2332
|
|
|
2337
2333
|
</h3><div class="docstring">
|
|
2338
2334
|
<div class="discussion">
|
|
2339
|
-
<p
|
|
2340
|
-
|
|
2335
|
+
<p class="note private">
|
|
2336
|
+
<strong>This method is part of a private API.</strong>
|
|
2337
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
2338
|
+
</p>
|
|
2339
|
+
<p>Allows <span class='object_link'><a href="" title="Mint::Money (class)">Mint::Money</a></span> to interact seamlessly as the right-hand operand in Numeric arithmetic.
|
|
2340
|
+
This enables expressions like <code>5 * money</code> where <code>5</code> is a Numeric and <code>money</code> is a Money object.</p>
|
|
2341
2341
|
|
|
2342
2342
|
</div>
|
|
2343
2343
|
</div>
|
|
@@ -2348,7 +2348,7 @@ This enables expressions like <code>5 + money</code> where <code>5</code> is a N
|
|
|
2348
2348
|
|
|
2349
2349
|
|
|
2350
2350
|
<pre class="example code"><code><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='int'>10</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>
|
|
2351
|
-
<span class='int'>5</span> <span class='op'
|
|
2351
|
+
<span class='int'>5</span> <span class='op'>*</span> <span class='id identifier rubyid_price'>price</span> <span class='comment'>#=> [USD 50.00] (via coercion)</span></code></pre>
|
|
2352
2352
|
|
|
2353
2353
|
</div>
|
|
2354
2354
|
<p class="tag_title">Parameters:</p>
|
|
@@ -2456,10 +2456,10 @@ This enables expressions like <code>5 + money</code> where <code>5</code> is a N
|
|
|
2456
2456
|
<pre class="lines">
|
|
2457
2457
|
|
|
2458
2458
|
|
|
2459
|
-
|
|
2459
|
+
29</pre>
|
|
2460
2460
|
</td>
|
|
2461
2461
|
<td>
|
|
2462
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
2462
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 29</span>
|
|
2463
2463
|
|
|
2464
2464
|
<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>
|
|
2465
2465
|
</td>
|
|
@@ -2478,7 +2478,8 @@ This enables expressions like <code>5 + money</code> where <code>5</code> is a N
|
|
|
2478
2478
|
|
|
2479
2479
|
</h3><div class="docstring">
|
|
2480
2480
|
<div class="discussion">
|
|
2481
|
-
|
|
2481
|
+
<p>Strict equality — both amount and currency must match exactly.
|
|
2482
|
+
Unlike ==, does not treat zero as equivalent across currencies.</p>
|
|
2482
2483
|
|
|
2483
2484
|
</div>
|
|
2484
2485
|
</div>
|
|
@@ -2504,14 +2505,14 @@ This enables expressions like <code>5 + money</code> where <code>5</code> is a N
|
|
|
2504
2505
|
<pre class="lines">
|
|
2505
2506
|
|
|
2506
2507
|
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2508
|
+
21
|
|
2509
|
+
22
|
|
2510
|
+
23
|
|
2511
|
+
24
|
|
2512
|
+
25</pre>
|
|
2512
2513
|
</td>
|
|
2513
2514
|
<td>
|
|
2514
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line
|
|
2515
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line 21</span>
|
|
2515
2516
|
|
|
2516
2517
|
<span class='kw'>def</span> <span class='id identifier rubyid_eql?'>eql?</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span>
|
|
2517
2518
|
<span class='id identifier rubyid_other'>other</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="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></span><span class='rparen'>)</span> <span class='op'>&&</span>
|
|
@@ -2574,10 +2575,10 @@ For example, cents for USD (subunit 2), yen for JPY (subunit 0), fils for IQD (s
|
|
|
2574
2575
|
<pre class="lines">
|
|
2575
2576
|
|
|
2576
2577
|
|
|
2577
|
-
|
|
2578
|
+
39</pre>
|
|
2578
2579
|
</td>
|
|
2579
2580
|
<td>
|
|
2580
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
2581
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 39</span>
|
|
2581
2582
|
|
|
2582
2583
|
<span class='kw'>def</span> <span class='id identifier rubyid_fractional'>fractional</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>
|
|
2583
2584
|
</td>
|
|
@@ -2625,10 +2626,10 @@ For example, cents for USD (subunit 2), yen for JPY (subunit 0), fils for IQD (s
|
|
|
2625
2626
|
<pre class="lines">
|
|
2626
2627
|
|
|
2627
2628
|
|
|
2628
|
-
|
|
2629
|
+
44</pre>
|
|
2629
2630
|
</td>
|
|
2630
2631
|
<td>
|
|
2631
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
2632
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 44</span>
|
|
2632
2633
|
|
|
2633
2634
|
<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>
|
|
2634
2635
|
</td>
|
|
@@ -2676,12 +2677,12 @@ For example, cents for USD (subunit 2), yen for JPY (subunit 0), fils for IQD (s
|
|
|
2676
2677
|
<pre class="lines">
|
|
2677
2678
|
|
|
2678
2679
|
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2680
|
+
49
|
|
2681
|
+
50
|
|
2682
|
+
51</pre>
|
|
2682
2683
|
</td>
|
|
2683
2684
|
<td>
|
|
2684
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
2685
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 49</span>
|
|
2685
2686
|
|
|
2686
2687
|
<span class='kw'>def</span> <span class='id identifier rubyid_inspect'>inspect</span>
|
|
2687
2688
|
<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>
|
|
@@ -2761,17 +2762,31 @@ while preserving immutability.</p>
|
|
|
2761
2762
|
<pre class="lines">
|
|
2762
2763
|
|
|
2763
2764
|
|
|
2765
|
+
55
|
|
2766
|
+
56
|
|
2764
2767
|
57
|
|
2765
2768
|
58
|
|
2766
2769
|
59
|
|
2767
|
-
60
|
|
2770
|
+
60
|
|
2771
|
+
61
|
|
2772
|
+
62
|
|
2773
|
+
63
|
|
2774
|
+
64
|
|
2775
|
+
65</pre>
|
|
2768
2776
|
</td>
|
|
2769
2777
|
<td>
|
|
2770
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line
|
|
2778
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/constructors.rb', line 55</span>
|
|
2771
2779
|
|
|
2772
2780
|
<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>
|
|
2773
2781
|
<span class='id identifier rubyid_new_amount'>new_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_new_amount'>new_amount</span><span class='rparen'>)</span>
|
|
2774
|
-
|
|
2782
|
+
|
|
2783
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_new_amount'>new_amount</span> <span class='op'>==</span> <span class='id identifier rubyid_amount'>amount</span>
|
|
2784
|
+
<span class='kw'>self</span>
|
|
2785
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_new_amount'>new_amount</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</span>
|
|
2786
|
+
<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_zero'><span class='object_link'><a href="../Mint.html#zero-class_method" title="Mint.zero (method)">zero</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
2787
|
+
<span class='kw'>else</span>
|
|
2788
|
+
<span class='const'><span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_new_amount'>new_amount</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
2789
|
+
<span class='kw'>end</span>
|
|
2775
2790
|
<span class='kw'>end</span></pre>
|
|
2776
2791
|
</td>
|
|
2777
2792
|
</tr>
|
|
@@ -2821,7 +2836,7 @@ while preserving immutability.</p>
|
|
|
2821
2836
|
14</pre>
|
|
2822
2837
|
</td>
|
|
2823
2838
|
<td>
|
|
2824
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line 14</span>
|
|
2839
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/methods.rb', line 14</span>
|
|
2825
2840
|
|
|
2826
2841
|
<span class='kw'>def</span> <span class='id identifier rubyid_negative?'>negative?</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_negative?'>negative?</span></pre>
|
|
2827
2842
|
</td>
|
|
@@ -2832,7 +2847,7 @@ while preserving immutability.</p>
|
|
|
2832
2847
|
<div class="method_details ">
|
|
2833
2848
|
<h3 class="signature " id="nonzero?-instance_method">
|
|
2834
2849
|
|
|
2835
|
-
#<strong>nonzero?</strong> ⇒ <tt>
|
|
2850
|
+
#<strong>nonzero?</strong> ⇒ <tt>self</tt><sup>?</sup>
|
|
2836
2851
|
|
|
2837
2852
|
|
|
2838
2853
|
|
|
@@ -2840,7 +2855,7 @@ while preserving immutability.</p>
|
|
|
2840
2855
|
|
|
2841
2856
|
</h3><div class="docstring">
|
|
2842
2857
|
<div class="discussion">
|
|
2843
|
-
|
|
2858
|
+
<p>Returns self if amount is non-zero, nil otherwise.</p>
|
|
2844
2859
|
|
|
2845
2860
|
</div>
|
|
2846
2861
|
</div>
|
|
@@ -2852,9 +2867,12 @@ while preserving immutability.</p>
|
|
|
2852
2867
|
<li>
|
|
2853
2868
|
|
|
2854
2869
|
|
|
2855
|
-
<span class='type'>(<tt>
|
|
2870
|
+
<span class='type'>(<tt>self</tt>, <tt>nil</tt>)</span>
|
|
2871
|
+
|
|
2856
2872
|
|
|
2857
2873
|
|
|
2874
|
+
—
|
|
2875
|
+
<div class='inline'><p>self if amount is non-zero, nil otherwise</p></div>
|
|
2858
2876
|
|
|
2859
2877
|
</li>
|
|
2860
2878
|
|
|
@@ -2866,10 +2884,10 @@ while preserving immutability.</p>
|
|
|
2866
2884
|
<pre class="lines">
|
|
2867
2885
|
|
|
2868
2886
|
|
|
2869
|
-
|
|
2887
|
+
45</pre>
|
|
2870
2888
|
</td>
|
|
2871
2889
|
<td>
|
|
2872
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line
|
|
2890
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line 45</span>
|
|
2873
2891
|
|
|
2874
2892
|
<span class='kw'>def</span> <span class='id identifier rubyid_nonzero?'>nonzero?</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_nonzero?'>nonzero?</span></pre>
|
|
2875
2893
|
</td>
|
|
@@ -2920,7 +2938,7 @@ while preserving immutability.</p>
|
|
|
2920
2938
|
19</pre>
|
|
2921
2939
|
</td>
|
|
2922
2940
|
<td>
|
|
2923
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line 19</span>
|
|
2941
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/methods.rb', line 19</span>
|
|
2924
2942
|
|
|
2925
2943
|
<span class='kw'>def</span> <span class='id identifier rubyid_positive?'>positive?</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_positive?'>positive?</span></pre>
|
|
2926
2944
|
</td>
|
|
@@ -2986,10 +3004,10 @@ while preserving immutability.</p>
|
|
|
2986
3004
|
<pre class="lines">
|
|
2987
3005
|
|
|
2988
3006
|
|
|
2989
|
-
|
|
3007
|
+
57</pre>
|
|
2990
3008
|
</td>
|
|
2991
3009
|
<td>
|
|
2992
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line
|
|
3010
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/money.rb', line 57</span>
|
|
2993
3011
|
|
|
2994
3012
|
<span class='kw'>def</span> <span class='id identifier rubyid_same_currency?'>same_currency?</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_currency'>currency</span> <span class='op'>==</span> <span class='id identifier rubyid_currency'>currency</span></pre>
|
|
2995
3013
|
</td>
|
|
@@ -3000,7 +3018,7 @@ while preserving immutability.</p>
|
|
|
3000
3018
|
<div class="method_details ">
|
|
3001
3019
|
<h3 class="signature " id="split-instance_method">
|
|
3002
3020
|
|
|
3003
|
-
#<strong>split</strong>(
|
|
3021
|
+
#<strong>split</strong>(slices) ⇒ <tt>Array<<span class='object_link'><a href="" title="Mint::Money (class)">Money</a></span>></tt>
|
|
3004
3022
|
|
|
3005
3023
|
|
|
3006
3024
|
|
|
@@ -3031,7 +3049,7 @@ so that the sum is preserved.</p>
|
|
|
3031
3049
|
|
|
3032
3050
|
<li>
|
|
3033
3051
|
|
|
3034
|
-
<span class='name'>
|
|
3052
|
+
<span class='name'>slices</span>
|
|
3035
3053
|
|
|
3036
3054
|
|
|
3037
3055
|
<span class='type'>(<tt>Integer</tt>)</span>
|
|
@@ -3084,29 +3102,23 @@ so that the sum is preserved.</p>
|
|
|
3084
3102
|
<pre class="lines">
|
|
3085
3103
|
|
|
3086
3104
|
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
43
|
|
3095
|
-
44
|
|
3096
|
-
45</pre>
|
|
3105
|
+
17
|
|
3106
|
+
18
|
|
3107
|
+
19
|
|
3108
|
+
20
|
|
3109
|
+
21
|
|
3110
|
+
22
|
|
3111
|
+
23</pre>
|
|
3097
3112
|
</td>
|
|
3098
3113
|
<td>
|
|
3099
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/allocation.rb', line
|
|
3114
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/allocation/split.rb', line 17</span>
|
|
3100
3115
|
|
|
3101
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='id identifier
|
|
3102
|
-
<span class='kw'>unless</span>
|
|
3103
|
-
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span>
|
|
3104
|
-
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>quantity must be an integer > 0</span><span class='tstring_end'>'</span></span>
|
|
3105
|
-
<span class='kw'>end</span>
|
|
3116
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='id identifier rubyid_slices'>slices</span><span class='rparen'>)</span>
|
|
3117
|
+
<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'>Slices quantity must be an poitive integer</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_slices'>slices</span><span class='period'>.</span><span class='id identifier rubyid_positive?'>positive?</span> <span class='op'>&&</span> <span class='id identifier rubyid_slices'>slices</span><span class='period'>.</span><span class='id identifier rubyid_integer?'>integer?</span>
|
|
3106
3118
|
|
|
3107
|
-
<span class='id identifier rubyid_fraction'>fraction</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
|
|
3108
|
-
<span class='id identifier rubyid_allocate_left_over
|
|
3109
|
-
|
|
3119
|
+
<span class='id identifier rubyid_fraction'>fraction</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_slices'>slices</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_subunit'>subunit</span><span class='rparen'>)</span>
|
|
3120
|
+
<span class='id identifier rubyid_allocate_left_over'>allocate_left_over</span><span class='lparen'>(</span><span class='label'>amounts:</span> <span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_slices'>slices</span><span class='comma'>,</span> <span class='id identifier rubyid_fraction'>fraction</span><span class='rparen'>)</span><span class='comma'>,</span>
|
|
3121
|
+
<span class='label'>left_over:</span> <span class='id identifier rubyid_amount'>amount</span> <span class='op'>-</span> <span class='lparen'>(</span><span class='id identifier rubyid_fraction'>fraction</span> <span class='op'>*</span> <span class='id identifier rubyid_slices'>slices</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
3110
3122
|
<span class='kw'>end</span></pre>
|
|
3111
3123
|
</td>
|
|
3112
3124
|
</tr>
|
|
@@ -3157,7 +3169,7 @@ Enables standard ranges and stepping (e.g. <code>1.dollar..10.dollars</code>).</
|
|
|
3157
3169
|
25</pre>
|
|
3158
3170
|
</td>
|
|
3159
3171
|
<td>
|
|
3160
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics.rb', line 25</span>
|
|
3172
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/arithmetics/methods.rb', line 25</span>
|
|
3161
3173
|
|
|
3162
3174
|
<span class='kw'>def</span> <span class='id identifier rubyid_succ'>succ</span> <span class='op'>=</span> <span class='id identifier rubyid_mint'>mint</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_minimum_amount'>minimum_amount</span><span class='rparen'>)</span></pre>
|
|
3163
3175
|
</td>
|
|
@@ -3594,7 +3606,7 @@ Highly optimized to run without external dependencies.</p>
|
|
|
3594
3606
|
<div class="method_details ">
|
|
3595
3607
|
<h3 class="signature " id="to_s-instance_method">
|
|
3596
3608
|
|
|
3597
|
-
#<strong>to_s</strong>(format:
|
|
3609
|
+
#<strong>to_s</strong>(format: nil, decimal: nil, thousand: nil, width: nil) ⇒ <tt>String</tt>
|
|
3598
3610
|
|
|
3599
3611
|
|
|
3600
3612
|
|
|
@@ -3640,6 +3652,11 @@ Highly optimized to run without external dependencies.</p>
|
|
|
3640
3652
|
<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"
|
|
3641
3653
|
</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>
|
|
3642
3654
|
|
|
3655
|
+
|
|
3656
|
+
<h5 class="example_title"><div class='inline'><p>Locale-aware formatting (with Mint.locale_backend set)</p></div></h5>
|
|
3657
|
+
|
|
3658
|
+
<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>
|
|
3659
|
+
|
|
3643
3660
|
</div>
|
|
3644
3661
|
<p class="tag_title">Parameters:</p>
|
|
3645
3662
|
<ul class="param">
|
|
@@ -3649,10 +3666,10 @@ Highly optimized to run without external dependencies.</p>
|
|
|
3649
3666
|
<span class='name'>format</span>
|
|
3650
3667
|
|
|
3651
3668
|
|
|
3652
|
-
<span class='type'>(<tt>String</tt>, <tt>Hash</tt>)</span>
|
|
3669
|
+
<span class='type'>(<tt>String</tt>, <tt>Hash</tt>, <tt>nil</tt>)</span>
|
|
3653
3670
|
|
|
3654
3671
|
|
|
3655
|
-
<em class="default">(defaults to: <tt
|
|
3672
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
3656
3673
|
|
|
3657
3674
|
|
|
3658
3675
|
—
|
|
@@ -3664,7 +3681,9 @@ is convenient for sign-aware formats such as accounting parentheses:</p>
|
|
|
3664
3681
|
</code></pre>
|
|
3665
3682
|
<p>Missing keys fall back to the module default, so a Hash with only
|
|
3666
3683
|
:negative will still format positives sensibly. The valid keys are
|
|
3667
|
-
:positive, :negative, :zero; anything else raises ArgumentError
|
|
3684
|
+
:positive, :negative, :zero; anything else raises ArgumentError.
|
|
3685
|
+
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise
|
|
3686
|
+
<code>"%<symbol>s%<amount>f"</code>.</p></div>
|
|
3668
3687
|
|
|
3669
3688
|
</li>
|
|
3670
3689
|
|
|
@@ -3673,14 +3692,15 @@ is convenient for sign-aware formats such as accounting parentheses:</p>
|
|
|
3673
3692
|
<span class='name'>thousand</span>
|
|
3674
3693
|
|
|
3675
3694
|
|
|
3676
|
-
<span class='type'>(<tt>String</tt>, <tt>false</tt>)</span>
|
|
3695
|
+
<span class='type'>(<tt>String</tt>, <tt>false</tt>, <tt>nil</tt>)</span>
|
|
3677
3696
|
|
|
3678
3697
|
|
|
3679
|
-
<em class="default">(defaults to: <tt
|
|
3698
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
3680
3699
|
|
|
3681
3700
|
|
|
3682
3701
|
—
|
|
3683
|
-
<div class='inline'><p>Thousands delimiter (e.g., ',' for 1,000)
|
|
3702
|
+
<div class='inline'><p>Thousands delimiter (e.g., ',' for 1,000).
|
|
3703
|
+
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise <code>","</code>.</p></div>
|
|
3684
3704
|
|
|
3685
3705
|
</li>
|
|
3686
3706
|
|
|
@@ -3689,14 +3709,15 @@ is convenient for sign-aware formats such as accounting parentheses:</p>
|
|
|
3689
3709
|
<span class='name'>decimal</span>
|
|
3690
3710
|
|
|
3691
3711
|
|
|
3692
|
-
<span class='type'>(<tt>String</tt>)</span>
|
|
3712
|
+
<span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
|
|
3693
3713
|
|
|
3694
3714
|
|
|
3695
|
-
<em class="default">(defaults to: <tt
|
|
3715
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
3696
3716
|
|
|
3697
3717
|
|
|
3698
3718
|
—
|
|
3699
|
-
<div class='inline'><p>Decimal separator (e.g., '.' or ',')
|
|
3719
|
+
<div class='inline'><p>Decimal separator (e.g., '.' or ',').
|
|
3720
|
+
When <code>nil</code>, falls back to <code>Mint.locale_backend</code> if set, otherwise <code>"."</code>.</p></div>
|
|
3700
3721
|
|
|
3701
3722
|
</li>
|
|
3702
3723
|
|
|
@@ -3742,13 +3763,6 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
3742
3763
|
<pre class="lines">
|
|
3743
3764
|
|
|
3744
3765
|
|
|
3745
|
-
46
|
|
3746
|
-
47
|
|
3747
|
-
48
|
|
3748
|
-
49
|
|
3749
|
-
50
|
|
3750
|
-
51
|
|
3751
|
-
52
|
|
3752
3766
|
53
|
|
3753
3767
|
54
|
|
3754
3768
|
55
|
|
@@ -3762,17 +3776,27 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
3762
3776
|
63
|
|
3763
3777
|
64
|
|
3764
3778
|
65
|
|
3765
|
-
66
|
|
3779
|
+
66
|
|
3780
|
+
67
|
|
3781
|
+
68
|
|
3782
|
+
69
|
|
3783
|
+
70
|
|
3784
|
+
71
|
|
3785
|
+
72
|
|
3786
|
+
73
|
|
3787
|
+
74</pre>
|
|
3766
3788
|
</td>
|
|
3767
3789
|
<td>
|
|
3768
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/
|
|
3790
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/format/to_s.rb', line 53</span>
|
|
3791
|
+
|
|
3792
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span><span class='lparen'>(</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>
|
|
3793
|
+
<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>
|
|
3769
3794
|
|
|
3770
|
-
<span class='kw'>def</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='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='comma'>,</span> <span class='label'>width:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
3771
3795
|
<span class='kw'>case</span> <span class='id identifier rubyid_format'>format</span>
|
|
3772
|
-
<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
|
|
3773
|
-
<span class='kw'>when</span> <span class='const'>Hash</span>
|
|
3774
|
-
<span class='kw'>when</span> <span class='const'>String</span> <span class='
|
|
3775
|
-
|
|
3796
|
+
<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>
|
|
3797
|
+
<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>
|
|
3798
|
+
<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>
|
|
3799
|
+
<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>
|
|
3776
3800
|
<span class='kw'>end</span>
|
|
3777
3801
|
|
|
3778
3802
|
<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='rparen'>)</span>
|
|
@@ -3785,8 +3809,7 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
3785
3809
|
</span> <span class='id identifier rubyid_formatted'>formatted</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]{1}|$))</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\1</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_thousand'>thousand</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
|
3786
3810
|
<span class='kw'>end</span>
|
|
3787
3811
|
|
|
3788
|
-
<span class='id identifier
|
|
3789
|
-
<span class='id identifier rubyid_formatted'>formatted</span>
|
|
3812
|
+
<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>
|
|
3790
3813
|
<span class='kw'>end</span></pre>
|
|
3791
3814
|
</td>
|
|
3792
3815
|
</tr>
|
|
@@ -3804,7 +3827,7 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
3804
3827
|
|
|
3805
3828
|
</h3><div class="docstring">
|
|
3806
3829
|
<div class="discussion">
|
|
3807
|
-
|
|
3830
|
+
<p>Returns true if amount is zero.</p>
|
|
3808
3831
|
|
|
3809
3832
|
</div>
|
|
3810
3833
|
</div>
|
|
@@ -3820,6 +3843,9 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
3820
3843
|
|
|
3821
3844
|
|
|
3822
3845
|
|
|
3846
|
+
—
|
|
3847
|
+
<div class='inline'><p>true if amount is zero</p></div>
|
|
3848
|
+
|
|
3823
3849
|
</li>
|
|
3824
3850
|
|
|
3825
3851
|
</ul>
|
|
@@ -3830,10 +3856,10 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
3830
3856
|
<pre class="lines">
|
|
3831
3857
|
|
|
3832
3858
|
|
|
3833
|
-
|
|
3859
|
+
48</pre>
|
|
3834
3860
|
</td>
|
|
3835
3861
|
<td>
|
|
3836
|
-
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line
|
|
3862
|
+
<pre class="code"><span class="info file"># File 'lib/minting/money/comparable.rb', line 48</span>
|
|
3837
3863
|
|
|
3838
3864
|
<span class='kw'>def</span> <span class='id identifier rubyid_zero?'>zero?</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</span></pre>
|
|
3839
3865
|
</td>
|
|
@@ -3846,9 +3872,9 @@ is empty, or the Hash contains an unrecognised key.</p></div>
|
|
|
3846
3872
|
</div>
|
|
3847
3873
|
|
|
3848
3874
|
<div id="footer">
|
|
3849
|
-
Generated on
|
|
3875
|
+
Generated on Mon Jun 15 19:57:57 2026 by
|
|
3850
3876
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
3851
|
-
0.9.44 (ruby-4.0.
|
|
3877
|
+
0.9.44 (ruby-4.0.5).
|
|
3852
3878
|
</div>
|
|
3853
3879
|
|
|
3854
3880
|
</div>
|