minting 1.7.3 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -8
- data/doc/Mint/Currency.html +535 -18
- data/doc/Mint/Money.html +659 -185
- data/doc/Mint/RangeStepPatch.html +1 -1
- data/doc/Mint/Registry.html +19 -2
- data/doc/Mint/Rounding.html +495 -0
- data/doc/Mint/UnknownCurrency.html +1 -1
- data/doc/Mint.html +187 -399
- data/doc/Minting.html +2 -2
- data/doc/_index.html +8 -1
- data/doc/agents/api_review-2026-06-15.md +0 -13
- data/doc/agents/copilot-instructions.md +70 -0
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +19 -9
- data/doc/index.html +19 -9
- data/doc/method_list.html +130 -42
- data/doc/top-level-namespace.html +1 -1
- data/lib/minting/currency/currency.rb +41 -2
- data/lib/minting/mint/dsl/range.rb +1 -0
- data/lib/minting/mint/mint.rb +10 -37
- data/lib/minting/mint/parser/parser.rb +50 -15
- data/lib/minting/mint/parser/separators.rb +10 -8
- data/lib/minting/mint/registry/zeros.rb +2 -0
- data/lib/minting/mint/rounding.rb +51 -0
- data/lib/minting/mint.rb +1 -0
- data/lib/minting/money/allocation/allocation.rb +1 -2
- data/lib/minting/money/allocation/split.rb +1 -1
- data/lib/minting/money/arithmetics/methods.rb +2 -2
- data/lib/minting/money/arithmetics/operators.rb +6 -6
- data/lib/minting/money/clamp.rb +1 -1
- data/lib/minting/money/coercion.rb +1 -1
- data/lib/minting/money/comparable.rb +6 -0
- data/lib/minting/money/constructors.rb +60 -12
- data/lib/minting/money/money.rb +0 -6
- data/lib/minting/version.rb +1 -1
- metadata +4 -1
|
@@ -267,7 +267,7 @@ Overrides Range#step to handle Mint::Money step sizes on Ruby < 4.0.</p>
|
|
|
267
267
|
</div>
|
|
268
268
|
|
|
269
269
|
<div id="footer">
|
|
270
|
-
Generated on
|
|
270
|
+
Generated on Tue Jun 16 20:22:19 2026 by
|
|
271
271
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
272
272
|
0.9.44 (ruby-4.0.5).
|
|
273
273
|
</div>
|
data/doc/Mint/Registry.html
CHANGED
|
@@ -633,6 +633,19 @@
|
|
|
633
633
|
|
|
634
634
|
</li>
|
|
635
635
|
|
|
636
|
+
</ul>
|
|
637
|
+
<p class="tag_title">Raises:</p>
|
|
638
|
+
<ul class="raise">
|
|
639
|
+
|
|
640
|
+
<li>
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
</li>
|
|
648
|
+
|
|
636
649
|
</ul>
|
|
637
650
|
|
|
638
651
|
</div><table class="source_code">
|
|
@@ -646,12 +659,16 @@
|
|
|
646
659
|
13
|
|
647
660
|
14
|
|
648
661
|
15
|
|
649
|
-
16
|
|
662
|
+
16
|
|
663
|
+
17
|
|
664
|
+
18</pre>
|
|
650
665
|
</td>
|
|
651
666
|
<td>
|
|
652
667
|
<pre class="code"><span class="info file"># File 'lib/minting/mint/registry/zeros.rb', line 11</span>
|
|
653
668
|
|
|
654
669
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_zero_for'>zero_for</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
670
|
+
<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'>Expect a Currency param. (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_currency'>currency</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="Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='rparen'>)</span>
|
|
671
|
+
|
|
655
672
|
<span class='const'>MUTEX</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='kw'>do</span>
|
|
656
673
|
<span class='ivar'>@zeros</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
657
674
|
<span class='ivar'>@zeros</span><span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:new</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
|
|
@@ -832,7 +849,7 @@
|
|
|
832
849
|
</div>
|
|
833
850
|
|
|
834
851
|
<div id="footer">
|
|
835
|
-
Generated on
|
|
852
|
+
Generated on Tue Jun 16 20:22:19 2026 by
|
|
836
853
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
837
854
|
0.9.44 (ruby-4.0.5).
|
|
838
855
|
</div>
|
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>
|
|
7
|
+
Module: Mint::Rounding
|
|
8
|
+
|
|
9
|
+
— Documentation by YARD 0.9.44
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css">
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css">
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript">
|
|
18
|
+
pathId = "Mint::Rounding";
|
|
19
|
+
relpath = '../';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|
24
|
+
|
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div id="main_progress" aria-hidden="true"></div>
|
|
31
|
+
|
|
32
|
+
<div class="nav_wrap">
|
|
33
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
|
34
|
+
<div id="resizer"></div>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div id="main" tabindex="-1">
|
|
38
|
+
<div id="header">
|
|
39
|
+
<div id="menu">
|
|
40
|
+
|
|
41
|
+
<a href="../_index.html">Index (R)</a> »
|
|
42
|
+
<span class='title'><span class='object_link'><a href="../Mint.html" title="Mint (module)">Mint</a></span></span>
|
|
43
|
+
»
|
|
44
|
+
<span class="title">Rounding</span>
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div id="search">
|
|
49
|
+
|
|
50
|
+
<a class="full_list_link" id="class_list_link"
|
|
51
|
+
href="../class_list.html">
|
|
52
|
+
|
|
53
|
+
<svg width="24" height="24">
|
|
54
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
55
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
56
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
57
|
+
</svg>
|
|
58
|
+
</a>
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<div class="clear"></div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div id="content"><h1>Module: Mint::Rounding
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
<span class="private note title">Private</span>
|
|
68
|
+
</h1>
|
|
69
|
+
<div class="box_info">
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<dl>
|
|
82
|
+
<dt>Defined in:</dt>
|
|
83
|
+
<dd>lib/minting/mint/rounding.rb
|
|
84
|
+
</dd>
|
|
85
|
+
</dl>
|
|
86
|
+
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<h2>Overview</h2><div class="docstring">
|
|
90
|
+
<div class="discussion">
|
|
91
|
+
<p class="note private">
|
|
92
|
+
<strong>This module is part of a private API.</strong>
|
|
93
|
+
You should avoid using this module if possible, as it may be removed or be changed in the future.
|
|
94
|
+
</p>
|
|
95
|
+
<p>Rounding-mode dispatch table and block-scoped context.</p>
|
|
96
|
+
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
<div class="tags">
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<h2>
|
|
105
|
+
Constant Summary
|
|
106
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
|
107
|
+
</h2>
|
|
108
|
+
|
|
109
|
+
<dl class="constants">
|
|
110
|
+
|
|
111
|
+
<dt id="MODES-constant" class="">MODES =
|
|
112
|
+
<div class="docstring">
|
|
113
|
+
<div class="discussion">
|
|
114
|
+
<p class="note private">
|
|
115
|
+
<strong>This constant is part of a private API.</strong>
|
|
116
|
+
You should avoid using this constant if possible, as it may be removed or be changed in the future.
|
|
117
|
+
</p>
|
|
118
|
+
<p>Maps mode symbols to their corresponding <code>Rational</code> rounding lambdas.</p>
|
|
119
|
+
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
<div class="tags">
|
|
123
|
+
|
|
124
|
+
<p class="tag_title">Returns:</p>
|
|
125
|
+
<ul class="return">
|
|
126
|
+
|
|
127
|
+
<li>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
<span class='type'>(<tt>Hash{Symbol => Proc}</tt>)</span>
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
</li>
|
|
135
|
+
|
|
136
|
+
</ul>
|
|
137
|
+
|
|
138
|
+
</div>
|
|
139
|
+
</dt>
|
|
140
|
+
<dd><pre class="code"><span class='lbrace'>{</span>
|
|
141
|
+
<span class='label'>half_up:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='id identifier rubyid_ndigits'>ndigits</span><span class='comma'>,</span> <span class='label'>half:</span> <span class='symbol'>:up</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
142
|
+
<span class='label'>half_down:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='id identifier rubyid_ndigits'>ndigits</span><span class='comma'>,</span> <span class='label'>half:</span> <span class='symbol'>:down</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
143
|
+
<span class='label'>floor:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_floor'>floor</span><span class='lparen'>(</span><span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
144
|
+
<span class='label'>ceil:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_ceil'>ceil</span><span class='lparen'>(</span><span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
145
|
+
<span class='label'>truncate:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_truncate'>truncate</span><span class='lparen'>(</span><span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
|
|
146
|
+
<span class='label'>down:</span> <span class='tlambda'>-></span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_truncate'>truncate</span><span class='lparen'>(</span><span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|
147
|
+
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
148
|
+
|
|
149
|
+
</dl>
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
<h2>
|
|
160
|
+
Class Method Summary
|
|
161
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
162
|
+
</h2>
|
|
163
|
+
|
|
164
|
+
<ul class="summary">
|
|
165
|
+
|
|
166
|
+
<li class="public ">
|
|
167
|
+
<span class="summary_signature">
|
|
168
|
+
|
|
169
|
+
<a href="#apply-class_method" title="apply (class method)">.<strong>apply</strong>(amount, ndigits) ⇒ Rational </a>
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
</span>
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
<span class="private note title">private</span>
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
<span class="summary_desc"><div class='inline'><p>Rounds <code>amount</code> to <code>ndigits</code> using the currently scoped rounding mode.</p></div></span>
|
|
184
|
+
|
|
185
|
+
</li>
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<li class="public ">
|
|
189
|
+
<span class="summary_signature">
|
|
190
|
+
|
|
191
|
+
<a href="#current_mode-class_method" title="current_mode (class method)">.<strong>current_mode</strong> ⇒ Symbol </a>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
</span>
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
<span class="private note title">private</span>
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<span class="summary_desc"><div class='inline'><p>Returns the currently active rounding mode, falling back to <code>:half_up</code>.</p></div></span>
|
|
206
|
+
|
|
207
|
+
</li>
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
<li class="public ">
|
|
211
|
+
<span class="summary_signature">
|
|
212
|
+
|
|
213
|
+
<a href="#with_mode-class_method" title="with_mode (class method)">.<strong>with_mode</strong>(mode) { ... } ⇒ Object </a>
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
</span>
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
<span class="private note title">private</span>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
<span class="summary_desc"><div class='inline'><p>Sets a rounding mode for the duration of a block, restoring the previous mode on exit (even on exception).</p></div></span>
|
|
228
|
+
|
|
229
|
+
</li>
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
</ul>
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
<div id="class_method_details" class="method_details_list">
|
|
239
|
+
<h2>Class Method Details</h2>
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
<div class="method_details first">
|
|
243
|
+
<h3 class="signature first" id="apply-class_method">
|
|
244
|
+
|
|
245
|
+
.<strong>apply</strong>(amount, ndigits) ⇒ <tt>Rational</tt>
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
</h3><div class="docstring">
|
|
252
|
+
<div class="discussion">
|
|
253
|
+
<p class="note private">
|
|
254
|
+
<strong>This method is part of a private API.</strong>
|
|
255
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
256
|
+
</p>
|
|
257
|
+
<p>Rounds <code>amount</code> to <code>ndigits</code> using the currently scoped rounding mode.</p>
|
|
258
|
+
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
<div class="tags">
|
|
262
|
+
<p class="tag_title">Parameters:</p>
|
|
263
|
+
<ul class="param">
|
|
264
|
+
|
|
265
|
+
<li>
|
|
266
|
+
|
|
267
|
+
<span class='name'>amount</span>
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
<span class='type'>(<tt>Numeric</tt>)</span>
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
</li>
|
|
275
|
+
|
|
276
|
+
<li>
|
|
277
|
+
|
|
278
|
+
<span class='name'>ndigits</span>
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
</li>
|
|
286
|
+
|
|
287
|
+
</ul>
|
|
288
|
+
|
|
289
|
+
<p class="tag_title">Returns:</p>
|
|
290
|
+
<ul class="return">
|
|
291
|
+
|
|
292
|
+
<li>
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
<span class='type'>(<tt>Rational</tt>)</span>
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
</li>
|
|
300
|
+
|
|
301
|
+
</ul>
|
|
302
|
+
|
|
303
|
+
</div><table class="source_code">
|
|
304
|
+
<tr>
|
|
305
|
+
<td>
|
|
306
|
+
<pre class="lines">
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
31
|
|
310
|
+
32
|
|
311
|
+
33</pre>
|
|
312
|
+
</td>
|
|
313
|
+
<td>
|
|
314
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/rounding.rb', line 31</span>
|
|
315
|
+
|
|
316
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_apply'>apply</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span>
|
|
317
|
+
<span class='const'><span class='object_link'><a href="#MODES-constant" title="Mint::Rounding::MODES (constant)">MODES</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_current_mode'>current_mode</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_r'>to_r</span><span class='comma'>,</span> <span class='id identifier rubyid_ndigits'>ndigits</span><span class='rparen'>)</span>
|
|
318
|
+
<span class='kw'>end</span></pre>
|
|
319
|
+
</td>
|
|
320
|
+
</tr>
|
|
321
|
+
</table>
|
|
322
|
+
</div>
|
|
323
|
+
|
|
324
|
+
<div class="method_details ">
|
|
325
|
+
<h3 class="signature " id="current_mode-class_method">
|
|
326
|
+
|
|
327
|
+
.<strong>current_mode</strong> ⇒ <tt>Symbol</tt>
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
</h3><div class="docstring">
|
|
334
|
+
<div class="discussion">
|
|
335
|
+
<p class="note private">
|
|
336
|
+
<strong>This method is part of a private API.</strong>
|
|
337
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
338
|
+
</p>
|
|
339
|
+
<p>Returns the currently active rounding mode, falling back to <code>:half_up</code>.</p>
|
|
340
|
+
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
<div class="tags">
|
|
344
|
+
|
|
345
|
+
<p class="tag_title">Returns:</p>
|
|
346
|
+
<ul class="return">
|
|
347
|
+
|
|
348
|
+
<li>
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
</li>
|
|
356
|
+
|
|
357
|
+
</ul>
|
|
358
|
+
|
|
359
|
+
</div><table class="source_code">
|
|
360
|
+
<tr>
|
|
361
|
+
<td>
|
|
362
|
+
<pre class="lines">
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
22
|
|
366
|
+
23
|
|
367
|
+
24</pre>
|
|
368
|
+
</td>
|
|
369
|
+
<td>
|
|
370
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/rounding.rb', line 22</span>
|
|
371
|
+
|
|
372
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_current_mode'>current_mode</span>
|
|
373
|
+
<span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:minting_rounding_mode</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='symbol'>:half_up</span>
|
|
374
|
+
<span class='kw'>end</span></pre>
|
|
375
|
+
</td>
|
|
376
|
+
</tr>
|
|
377
|
+
</table>
|
|
378
|
+
</div>
|
|
379
|
+
|
|
380
|
+
<div class="method_details ">
|
|
381
|
+
<h3 class="signature " id="with_mode-class_method">
|
|
382
|
+
|
|
383
|
+
.<strong>with_mode</strong>(mode) { ... } ⇒ <tt>Object</tt>
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
</h3><div class="docstring">
|
|
390
|
+
<div class="discussion">
|
|
391
|
+
<p class="note private">
|
|
392
|
+
<strong>This method is part of a private API.</strong>
|
|
393
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
394
|
+
</p>
|
|
395
|
+
<p>Sets a rounding mode for the duration of a block, restoring the
|
|
396
|
+
previous mode on exit (even on exception).</p>
|
|
397
|
+
|
|
398
|
+
</div>
|
|
399
|
+
</div>
|
|
400
|
+
<div class="tags">
|
|
401
|
+
<p class="tag_title">Parameters:</p>
|
|
402
|
+
<ul class="param">
|
|
403
|
+
|
|
404
|
+
<li>
|
|
405
|
+
|
|
406
|
+
<span class='name'>mode</span>
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
</li>
|
|
414
|
+
|
|
415
|
+
</ul>
|
|
416
|
+
|
|
417
|
+
<p class="tag_title">Yields:</p>
|
|
418
|
+
<ul class="yield">
|
|
419
|
+
|
|
420
|
+
<li>
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
<span class='type'></span>
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
<div class='inline'><p>block to execute with the mode active</p></div>
|
|
429
|
+
|
|
430
|
+
</li>
|
|
431
|
+
|
|
432
|
+
</ul>
|
|
433
|
+
<p class="tag_title">Raises:</p>
|
|
434
|
+
<ul class="raise">
|
|
435
|
+
|
|
436
|
+
<li>
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
—
|
|
444
|
+
<div class='inline'><p>on unknown mode</p></div>
|
|
445
|
+
|
|
446
|
+
</li>
|
|
447
|
+
|
|
448
|
+
</ul>
|
|
449
|
+
|
|
450
|
+
</div><table class="source_code">
|
|
451
|
+
<tr>
|
|
452
|
+
<td>
|
|
453
|
+
<pre class="lines">
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
41
|
|
457
|
+
42
|
|
458
|
+
43
|
|
459
|
+
44
|
|
460
|
+
45
|
|
461
|
+
46
|
|
462
|
+
47
|
|
463
|
+
48
|
|
464
|
+
49</pre>
|
|
465
|
+
</td>
|
|
466
|
+
<td>
|
|
467
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/rounding.rb', line 41</span>
|
|
468
|
+
|
|
469
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_with_mode'>with_mode</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='rparen'>)</span>
|
|
470
|
+
<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 rounding mode: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mode'>mode</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='const'><span class='object_link'><a href="#MODES-constant" title="Mint::Rounding::MODES (constant)">MODES</a></span></span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_mode'>mode</span><span class='rparen'>)</span>
|
|
471
|
+
|
|
472
|
+
<span class='id identifier rubyid_prev'>prev</span> <span class='op'>=</span> <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:minting_rounding_mode</span><span class='rbracket'>]</span>
|
|
473
|
+
<span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:minting_rounding_mode</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_mode'>mode</span>
|
|
474
|
+
<span class='kw'>yield</span>
|
|
475
|
+
<span class='kw'>ensure</span>
|
|
476
|
+
<span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:minting_rounding_mode</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_prev'>prev</span>
|
|
477
|
+
<span class='kw'>end</span></pre>
|
|
478
|
+
</td>
|
|
479
|
+
</tr>
|
|
480
|
+
</table>
|
|
481
|
+
</div>
|
|
482
|
+
|
|
483
|
+
</div>
|
|
484
|
+
|
|
485
|
+
</div>
|
|
486
|
+
|
|
487
|
+
<div id="footer">
|
|
488
|
+
Generated on Tue Jun 16 20:22:19 2026 by
|
|
489
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
490
|
+
0.9.44 (ruby-4.0.5).
|
|
491
|
+
</div>
|
|
492
|
+
|
|
493
|
+
</div>
|
|
494
|
+
</body>
|
|
495
|
+
</html>
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
</div>
|
|
127
127
|
|
|
128
128
|
<div id="footer">
|
|
129
|
-
Generated on
|
|
129
|
+
Generated on Tue Jun 16 20:22:19 2026 by
|
|
130
130
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
131
131
|
0.9.44 (ruby-4.0.5).
|
|
132
132
|
</div>
|