minting 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -1
- data/doc/Mint/Currency.html +285 -31
- data/doc/Mint/Money.html +79 -56
- data/doc/Mint/RangeStepPatch.html +1 -1
- data/doc/Mint/Registry.html +842 -0
- data/doc/Mint/UnknownCurrency.html +1 -1
- data/doc/Mint.html +345 -51
- data/doc/Minting.html +2 -2
- data/doc/_index.html +8 -8
- data/doc/agents/api_review-2026-06-15.md +342 -0
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +13 -2
- data/doc/index.html +13 -2
- data/doc/method_list.html +100 -36
- data/doc/top-level-namespace.html +1 -1
- data/lib/minting/currency/currency.rb +31 -0
- data/lib/minting/mint/locale_backend.rb +29 -0
- data/lib/minting/mint/mint.rb +23 -21
- data/lib/minting/mint/parser/parser.rb +3 -7
- data/lib/minting/mint/registry/registration.rb +33 -0
- data/lib/minting/mint/registry/registry.rb +38 -0
- data/lib/minting/mint/registry/symbols.rb +49 -0
- data/lib/minting/mint/registry/zeros.rb +18 -0
- data/lib/minting/mint.rb +13 -25
- data/lib/minting/money/constructors.rb +6 -11
- data/lib/minting/money/format/formatting.rb +16 -0
- data/lib/minting/money/format/to_s.rb +13 -4
- data/lib/minting/money/money.rb +12 -0
- data/lib/minting/version.rb +1 -1
- metadata +13 -8
- data/lib/minting/currency/currency_registry.rb +0 -67
- data/lib/minting/currency/world_currencies.rb +0 -16
- /data/doc/agents/{AGENTS.md → expired/AGENTS.md} +0 -0
- /data/doc/agents/{copilot-instructions.md → expired/copilot-instructions.md} +0 -0
- /data/doc/agents/{gemini_gem_evaluation.md → expired/gemini_gem_evaluation.md} +0 -0
- /data/doc/agents/{recommendations.md → expired/recommendations.md} +0 -0
- /data/doc/agents/{rubocop-issues.md → expired/rubocop-issues.md} +0 -0
|
@@ -0,0 +1,842 @@
|
|
|
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::Registry
|
|
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::Registry";
|
|
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">Registry</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::Registry
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
</h1>
|
|
69
|
+
<div class="box_info">
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
<dl>
|
|
75
|
+
<dt>Extended by:</dt>
|
|
76
|
+
<dd><span class='object_link'><a href="" title="Mint::Registry (module)">Registry</a></span></dd>
|
|
77
|
+
</dl>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<dl>
|
|
85
|
+
<dt>Included in:</dt>
|
|
86
|
+
<dd><span class='object_link'><a href="" title="Mint::Registry (module)">Registry</a></span></dd>
|
|
87
|
+
</dl>
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
<dl>
|
|
92
|
+
<dt>Defined in:</dt>
|
|
93
|
+
<dd>lib/minting/mint/registry/zeros.rb<span class="defines">,<br>
|
|
94
|
+
lib/minting/mint/registry/symbols.rb,<br> lib/minting/mint/registry/registry.rb,<br> lib/minting/mint/registry/registration.rb</span>
|
|
95
|
+
|
|
96
|
+
</dd>
|
|
97
|
+
</dl>
|
|
98
|
+
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<h2>Overview</h2><div class="docstring">
|
|
102
|
+
<div class="discussion">
|
|
103
|
+
<p>:nodoc:</p>
|
|
104
|
+
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="tags">
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
<h2>
|
|
119
|
+
Class Method Summary
|
|
120
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
121
|
+
</h2>
|
|
122
|
+
|
|
123
|
+
<ul class="summary">
|
|
124
|
+
|
|
125
|
+
<li class="public ">
|
|
126
|
+
<span class="summary_signature">
|
|
127
|
+
|
|
128
|
+
<a href="#currencies-class_method" title="currencies (class method)">.<strong>currencies</strong> ⇒ Hash{String => Currency} </a>
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
</span>
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
<span class="private note title">private</span>
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
<span class="summary_desc"><div class='inline'><p>Returns the frozen hash of all registered currencies (world + custom).</p></div></span>
|
|
143
|
+
|
|
144
|
+
</li>
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
<li class="public ">
|
|
148
|
+
<span class="summary_signature">
|
|
149
|
+
|
|
150
|
+
<a href="#register-class_method" title="register (class method)">.<strong>register</strong>(code:, subunit: 0, symbol: '', priority: 0) ⇒ Currency </a>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
</span>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
<span class="summary_desc"><div class='inline'><p>Registers a new currency, raising a KeyError if already registered.</p></div></span>
|
|
165
|
+
|
|
166
|
+
</li>
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
<li class="public ">
|
|
170
|
+
<span class="summary_signature">
|
|
171
|
+
|
|
172
|
+
<a href="#world_currencies-class_method" title="world_currencies (class method)">.<strong>world_currencies</strong> ⇒ Hash{String => Currency} </a>
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
</span>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
<span class="private note title">private</span>
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
<span class="summary_desc"><div class='inline'><p>Loads ISO world currencies from YAML file.</p></div></span>
|
|
187
|
+
|
|
188
|
+
</li>
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
<li class="public ">
|
|
192
|
+
<span class="summary_signature">
|
|
193
|
+
|
|
194
|
+
<a href="#zero_for-class_method" title="zero_for (class method)">.<strong>zero_for</strong>(currency) ⇒ Money </a>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
</span>
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<span class="private note title">private</span>
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
<span class="summary_desc"><div class='inline'><p>Returns the cached zero-Money for a currency, creating it if needed.</p></div></span>
|
|
209
|
+
|
|
210
|
+
</li>
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
</ul>
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
<h2>
|
|
217
|
+
Instance Method Summary
|
|
218
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
219
|
+
</h2>
|
|
220
|
+
|
|
221
|
+
<ul class="summary">
|
|
222
|
+
|
|
223
|
+
<li class="public ">
|
|
224
|
+
<span class="summary_signature">
|
|
225
|
+
|
|
226
|
+
<a href="#currency_for_symbol-instance_method" title="#currency_for_symbol (instance method)">#<strong>currency_for_symbol</strong>(symbol) ⇒ Currency<sup>?</sup> </a>
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
</span>
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
<span class="private note title">private</span>
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
<span class="summary_desc"><div class='inline'><p>Looks up a currency by its display symbol.</p></div></span>
|
|
241
|
+
|
|
242
|
+
</li>
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
<li class="public ">
|
|
246
|
+
<span class="summary_signature">
|
|
247
|
+
|
|
248
|
+
<a href="#detect_currency-instance_method" title="#detect_currency (instance method)">#<strong>detect_currency</strong>(input) ⇒ Currency<sup>?</sup> </a>
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
</span>
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
<span class="private note title">private</span>
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
<span class="summary_desc"><div class='inline'><p>Scans <code>input</code> for registered currency symbols and returns the first match.</p></div></span>
|
|
263
|
+
|
|
264
|
+
</li>
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
</ul>
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
<div id="class_method_details" class="method_details_list">
|
|
274
|
+
<h2>Class Method Details</h2>
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
<div class="method_details first">
|
|
278
|
+
<h3 class="signature first" id="currencies-class_method">
|
|
279
|
+
|
|
280
|
+
.<strong>currencies</strong> ⇒ <tt>Hash{String => <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
</h3><div class="docstring">
|
|
287
|
+
<div class="discussion">
|
|
288
|
+
<p class="note private">
|
|
289
|
+
<strong>This method is part of a private API.</strong>
|
|
290
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
291
|
+
</p>
|
|
292
|
+
<p>Returns the frozen hash of all registered currencies (world + custom).</p>
|
|
293
|
+
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
<div class="tags">
|
|
297
|
+
|
|
298
|
+
<p class="tag_title">Returns:</p>
|
|
299
|
+
<ul class="return">
|
|
300
|
+
|
|
301
|
+
<li>
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
<span class='type'>(<tt>Hash{String => <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>)</span>
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
—
|
|
309
|
+
<div class='inline'><p>registered currencies mapped by code</p></div>
|
|
310
|
+
|
|
311
|
+
</li>
|
|
312
|
+
|
|
313
|
+
</ul>
|
|
314
|
+
|
|
315
|
+
</div><table class="source_code">
|
|
316
|
+
<tr>
|
|
317
|
+
<td>
|
|
318
|
+
<pre class="lines">
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
34
|
|
322
|
+
35
|
|
323
|
+
36</pre>
|
|
324
|
+
</td>
|
|
325
|
+
<td>
|
|
326
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/registry/registry.rb', line 34</span>
|
|
327
|
+
|
|
328
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_currencies'>currencies</span>
|
|
329
|
+
<span class='ivar'>@currencies</span> <span class='op'>||</span> <span class='const'>MUTEX</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='lbrace'>{</span> <span class='ivar'>@currencies</span> <span class='op'>=</span> <span class='id identifier rubyid_world_currencies'>world_currencies</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span> <span class='rbrace'>}</span>
|
|
330
|
+
<span class='kw'>end</span></pre>
|
|
331
|
+
</td>
|
|
332
|
+
</tr>
|
|
333
|
+
</table>
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
<div class="method_details ">
|
|
337
|
+
<h3 class="signature " id="register-class_method">
|
|
338
|
+
|
|
339
|
+
.<strong>register</strong>(code:, subunit: 0, symbol: '', priority: 0) ⇒ <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
</h3><div class="docstring">
|
|
346
|
+
<div class="discussion">
|
|
347
|
+
<p>Registers a new currency, raising a KeyError if already registered.</p>
|
|
348
|
+
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
<div class="tags">
|
|
352
|
+
<p class="tag_title">Parameters:</p>
|
|
353
|
+
<ul class="param">
|
|
354
|
+
|
|
355
|
+
<li>
|
|
356
|
+
|
|
357
|
+
<span class='name'>code</span>
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
—
|
|
365
|
+
<div class='inline'><p>the unique currency code</p></div>
|
|
366
|
+
|
|
367
|
+
</li>
|
|
368
|
+
|
|
369
|
+
<li>
|
|
370
|
+
|
|
371
|
+
<span class='name'>subunit</span>
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
—
|
|
381
|
+
<div class='inline'><p>the decimal subunit precision, defaults to 0</p></div>
|
|
382
|
+
|
|
383
|
+
</li>
|
|
384
|
+
|
|
385
|
+
<li>
|
|
386
|
+
|
|
387
|
+
<span class='name'>symbol</span>
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
<em class="default">(defaults to: <tt>''</tt>)</em>
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
—
|
|
397
|
+
<div class='inline'><p>the display symbol</p></div>
|
|
398
|
+
|
|
399
|
+
</li>
|
|
400
|
+
|
|
401
|
+
<li>
|
|
402
|
+
|
|
403
|
+
<span class='name'>priority</span>
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
—
|
|
413
|
+
<div class='inline'><p>parser precedence priority</p></div>
|
|
414
|
+
|
|
415
|
+
</li>
|
|
416
|
+
|
|
417
|
+
</ul>
|
|
418
|
+
|
|
419
|
+
<p class="tag_title">Returns:</p>
|
|
420
|
+
<ul class="return">
|
|
421
|
+
|
|
422
|
+
<li>
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
<span class='type'>(<tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
—
|
|
430
|
+
<div class='inline'><p>the newly registered Currency instance</p></div>
|
|
431
|
+
|
|
432
|
+
</li>
|
|
433
|
+
|
|
434
|
+
</ul>
|
|
435
|
+
<p class="tag_title">Raises:</p>
|
|
436
|
+
<ul class="raise">
|
|
437
|
+
|
|
438
|
+
<li>
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
—
|
|
446
|
+
<div class='inline'><p>if the code contains invalid characters</p></div>
|
|
447
|
+
|
|
448
|
+
</li>
|
|
449
|
+
|
|
450
|
+
<li>
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
<span class='type'>(<tt>KeyError</tt>)</span>
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
—
|
|
458
|
+
<div class='inline'><p>if the currency code is already registered</p></div>
|
|
459
|
+
|
|
460
|
+
</li>
|
|
461
|
+
|
|
462
|
+
</ul>
|
|
463
|
+
|
|
464
|
+
</div><table class="source_code">
|
|
465
|
+
<tr>
|
|
466
|
+
<td>
|
|
467
|
+
<pre class="lines">
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
15
|
|
471
|
+
16
|
|
472
|
+
17
|
|
473
|
+
18
|
|
474
|
+
19
|
|
475
|
+
20
|
|
476
|
+
21
|
|
477
|
+
22
|
|
478
|
+
23
|
|
479
|
+
24
|
|
480
|
+
25
|
|
481
|
+
26
|
|
482
|
+
27
|
|
483
|
+
28
|
|
484
|
+
29
|
|
485
|
+
30
|
|
486
|
+
31</pre>
|
|
487
|
+
</td>
|
|
488
|
+
<td>
|
|
489
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/registry/registration.rb', line 15</span>
|
|
490
|
+
|
|
491
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_register'>register</span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>subunit:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>symbol:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='rparen'>)</span>
|
|
492
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Currency code must be String</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_code'>code</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span>
|
|
493
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_code'>code</span><span class='period'>.</span><span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^[A-Z_]+$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
|
|
494
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span>
|
|
495
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Currency code must have only letters or '_' ('USD',, 'MY_COIN')</span><span class='tstring_end'>"</span></span>
|
|
496
|
+
<span class='kw'>end</span>
|
|
497
|
+
|
|
498
|
+
<span class='const'>MUTEX</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='kw'>do</span>
|
|
499
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>KeyError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Currency: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_code'>code</span><span class='embexpr_end'>}</span><span class='tstring_content'> already registered</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_currencies'>currencies</span><span class='lbracket'>[</span><span class='id identifier rubyid_code'>code</span><span class='rbracket'>]</span>
|
|
500
|
+
|
|
501
|
+
<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_new'><span class='object_link'><a href="Currency.html#initialize-instance_method" title="Mint::Currency#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>subunit:</span><span class='comma'>,</span> <span class='label'>symbol:</span><span class='comma'>,</span> <span class='label'>priority:</span><span class='rparen'>)</span>
|
|
502
|
+
<span class='ivar'>@currencies</span> <span class='op'>=</span> <span class='ivar'>@currencies</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_code'>code</span> <span class='op'>=></span> <span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
|
503
|
+
<span class='ivar'>@currency_symbols</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|
504
|
+
<span class='ivar'>@currency_symbol_map</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
|
505
|
+
<span class='id identifier rubyid_currency'>currency</span>
|
|
506
|
+
<span class='kw'>end</span>
|
|
507
|
+
<span class='kw'>end</span></pre>
|
|
508
|
+
</td>
|
|
509
|
+
</tr>
|
|
510
|
+
</table>
|
|
511
|
+
</div>
|
|
512
|
+
|
|
513
|
+
<div class="method_details ">
|
|
514
|
+
<h3 class="signature " id="world_currencies-class_method">
|
|
515
|
+
|
|
516
|
+
.<strong>world_currencies</strong> ⇒ <tt>Hash{String => <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
</h3><div class="docstring">
|
|
523
|
+
<div class="discussion">
|
|
524
|
+
<p class="note private">
|
|
525
|
+
<strong>This method is part of a private API.</strong>
|
|
526
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
527
|
+
</p>
|
|
528
|
+
<p>Loads ISO world currencies from YAML file.</p>
|
|
529
|
+
|
|
530
|
+
</div>
|
|
531
|
+
</div>
|
|
532
|
+
<div class="tags">
|
|
533
|
+
|
|
534
|
+
<p class="tag_title">Returns:</p>
|
|
535
|
+
<ul class="return">
|
|
536
|
+
|
|
537
|
+
<li>
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
<span class='type'>(<tt>Hash{String => <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>)</span>
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
—
|
|
545
|
+
<div class='inline'><p>ISO-4217 world currencies mapped by code</p></div>
|
|
546
|
+
|
|
547
|
+
</li>
|
|
548
|
+
|
|
549
|
+
</ul>
|
|
550
|
+
|
|
551
|
+
</div><table class="source_code">
|
|
552
|
+
<tr>
|
|
553
|
+
<td>
|
|
554
|
+
<pre class="lines">
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
21
|
|
558
|
+
22
|
|
559
|
+
23
|
|
560
|
+
24
|
|
561
|
+
25
|
|
562
|
+
26
|
|
563
|
+
27
|
|
564
|
+
28</pre>
|
|
565
|
+
</td>
|
|
566
|
+
<td>
|
|
567
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/registry/registry.rb', line 21</span>
|
|
568
|
+
|
|
569
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_world_currencies'>world_currencies</span>
|
|
570
|
+
<span class='ivar'>@world_currencies</span> <span class='op'>||</span> <span class='const'>MUTEX</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='kw'>do</span>
|
|
571
|
+
<span class='ivar'>@world_currencies</span> <span class='op'>=</span> <span class='kw'>begin</span>
|
|
572
|
+
<span class='id identifier rubyid_path'>path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>../../data</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid___dir__'>__dir__</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>world-currencies.yaml</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
|
573
|
+
<span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_load_file'>load_file</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_entry'>entry</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_entry'>entry</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>code</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</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_new'><span class='object_link'><a href="Currency.html#initialize-instance_method" title="Mint::Currency#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_transform_keys'>transform_keys</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
|
|
574
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
|
575
|
+
<span class='kw'>end</span>
|
|
576
|
+
<span class='kw'>end</span></pre>
|
|
577
|
+
</td>
|
|
578
|
+
</tr>
|
|
579
|
+
</table>
|
|
580
|
+
</div>
|
|
581
|
+
|
|
582
|
+
<div class="method_details ">
|
|
583
|
+
<h3 class="signature " id="zero_for-class_method">
|
|
584
|
+
|
|
585
|
+
.<strong>zero_for</strong>(currency) ⇒ <tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
</h3><div class="docstring">
|
|
592
|
+
<div class="discussion">
|
|
593
|
+
<p class="note private">
|
|
594
|
+
<strong>This method is part of a private API.</strong>
|
|
595
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
596
|
+
</p>
|
|
597
|
+
<p>Returns the cached zero-Money for a currency, creating it if needed.</p>
|
|
598
|
+
|
|
599
|
+
</div>
|
|
600
|
+
</div>
|
|
601
|
+
<div class="tags">
|
|
602
|
+
<p class="tag_title">Parameters:</p>
|
|
603
|
+
<ul class="param">
|
|
604
|
+
|
|
605
|
+
<li>
|
|
606
|
+
|
|
607
|
+
<span class='name'>currency</span>
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
<span class='type'>(<tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
—
|
|
615
|
+
<div class='inline'><p>the currency object</p></div>
|
|
616
|
+
|
|
617
|
+
</li>
|
|
618
|
+
|
|
619
|
+
</ul>
|
|
620
|
+
|
|
621
|
+
<p class="tag_title">Returns:</p>
|
|
622
|
+
<ul class="return">
|
|
623
|
+
|
|
624
|
+
<li>
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
<span class='type'>(<tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>)</span>
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
—
|
|
632
|
+
<div class='inline'><p>a frozen zero-Money</p></div>
|
|
633
|
+
|
|
634
|
+
</li>
|
|
635
|
+
|
|
636
|
+
</ul>
|
|
637
|
+
|
|
638
|
+
</div><table class="source_code">
|
|
639
|
+
<tr>
|
|
640
|
+
<td>
|
|
641
|
+
<pre class="lines">
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
11
|
|
645
|
+
12
|
|
646
|
+
13
|
|
647
|
+
14
|
|
648
|
+
15
|
|
649
|
+
16</pre>
|
|
650
|
+
</td>
|
|
651
|
+
<td>
|
|
652
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/registry/zeros.rb', line 11</span>
|
|
653
|
+
|
|
654
|
+
<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>
|
|
655
|
+
<span class='const'>MUTEX</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='kw'>do</span>
|
|
656
|
+
<span class='ivar'>@zeros</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
657
|
+
<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>
|
|
658
|
+
<span class='kw'>end</span>
|
|
659
|
+
<span class='kw'>end</span></pre>
|
|
660
|
+
</td>
|
|
661
|
+
</tr>
|
|
662
|
+
</table>
|
|
663
|
+
</div>
|
|
664
|
+
|
|
665
|
+
</div>
|
|
666
|
+
|
|
667
|
+
<div id="instance_method_details" class="method_details_list">
|
|
668
|
+
<h2>Instance Method Details</h2>
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
<div class="method_details first">
|
|
672
|
+
<h3 class="signature first" id="currency_for_symbol-instance_method">
|
|
673
|
+
|
|
674
|
+
#<strong>currency_for_symbol</strong>(symbol) ⇒ <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
</h3><div class="docstring">
|
|
681
|
+
<div class="discussion">
|
|
682
|
+
<p class="note private">
|
|
683
|
+
<strong>This method is part of a private API.</strong>
|
|
684
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
685
|
+
</p>
|
|
686
|
+
<p>Looks up a currency by its display symbol.</p>
|
|
687
|
+
|
|
688
|
+
</div>
|
|
689
|
+
</div>
|
|
690
|
+
<div class="tags">
|
|
691
|
+
<p class="tag_title">Parameters:</p>
|
|
692
|
+
<ul class="param">
|
|
693
|
+
|
|
694
|
+
<li>
|
|
695
|
+
|
|
696
|
+
<span class='name'>symbol</span>
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
—
|
|
704
|
+
<div class='inline'><p>the display symbol (e.g. "$", "R$")</p></div>
|
|
705
|
+
|
|
706
|
+
</li>
|
|
707
|
+
|
|
708
|
+
</ul>
|
|
709
|
+
|
|
710
|
+
<p class="tag_title">Returns:</p>
|
|
711
|
+
<ul class="return">
|
|
712
|
+
|
|
713
|
+
<li>
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
<span class='type'>(<tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
—
|
|
721
|
+
<div class='inline'><p>the highest-priority currency for the symbol</p></div>
|
|
722
|
+
|
|
723
|
+
</li>
|
|
724
|
+
|
|
725
|
+
</ul>
|
|
726
|
+
|
|
727
|
+
</div><table class="source_code">
|
|
728
|
+
<tr>
|
|
729
|
+
<td>
|
|
730
|
+
<pre class="lines">
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
13
|
|
734
|
+
14
|
|
735
|
+
15
|
|
736
|
+
16</pre>
|
|
737
|
+
</td>
|
|
738
|
+
<td>
|
|
739
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/registry/symbols.rb', line 13</span>
|
|
740
|
+
|
|
741
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_currency_for_symbol'>currency_for_symbol</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span>
|
|
742
|
+
<span class='ivar'>@currency_symbol_map</span> <span class='op'>||</span> <span class='const'>MUTEX</span><span class='period'>.</span><span class='id identifier rubyid_synchronize'>synchronize</span> <span class='lbrace'>{</span> <span class='ivar'>@currency_symbol_map</span> <span class='op'>=</span> <span class='id identifier rubyid_currency_symbols'>currency_symbols</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span> <span class='rbrace'>}</span>
|
|
743
|
+
<span class='ivar'>@currency_symbol_map</span><span class='lbracket'>[</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rbracket'>]</span>
|
|
744
|
+
<span class='kw'>end</span></pre>
|
|
745
|
+
</td>
|
|
746
|
+
</tr>
|
|
747
|
+
</table>
|
|
748
|
+
</div>
|
|
749
|
+
|
|
750
|
+
<div class="method_details ">
|
|
751
|
+
<h3 class="signature " id="detect_currency-instance_method">
|
|
752
|
+
|
|
753
|
+
#<strong>detect_currency</strong>(input) ⇒ <tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
</h3><div class="docstring">
|
|
760
|
+
<div class="discussion">
|
|
761
|
+
<p class="note private">
|
|
762
|
+
<strong>This method is part of a private API.</strong>
|
|
763
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
764
|
+
</p>
|
|
765
|
+
<p>Scans <code>input</code> for registered currency symbols and returns the first match.</p>
|
|
766
|
+
|
|
767
|
+
</div>
|
|
768
|
+
</div>
|
|
769
|
+
<div class="tags">
|
|
770
|
+
<p class="tag_title">Parameters:</p>
|
|
771
|
+
<ul class="param">
|
|
772
|
+
|
|
773
|
+
<li>
|
|
774
|
+
|
|
775
|
+
<span class='name'>input</span>
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
—
|
|
783
|
+
<div class='inline'><p>the string to scan</p></div>
|
|
784
|
+
|
|
785
|
+
</li>
|
|
786
|
+
|
|
787
|
+
</ul>
|
|
788
|
+
|
|
789
|
+
<p class="tag_title">Returns:</p>
|
|
790
|
+
<ul class="return">
|
|
791
|
+
|
|
792
|
+
<li>
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
<span class='type'>(<tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
</li>
|
|
800
|
+
|
|
801
|
+
</ul>
|
|
802
|
+
|
|
803
|
+
</div><table class="source_code">
|
|
804
|
+
<tr>
|
|
805
|
+
<td>
|
|
806
|
+
<pre class="lines">
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
23
|
|
810
|
+
24
|
|
811
|
+
25
|
|
812
|
+
26
|
|
813
|
+
27
|
|
814
|
+
28</pre>
|
|
815
|
+
</td>
|
|
816
|
+
<td>
|
|
817
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/registry/symbols.rb', line 23</span>
|
|
818
|
+
|
|
819
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_detect_currency'>detect_currency</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
|
|
820
|
+
<span class='id identifier rubyid_currency_symbols'>currency_symbols</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='op'>|</span>
|
|
821
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_currency'>currency</span> <span class='kw'>if</span> <span class='id identifier rubyid_input'>input</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span>
|
|
822
|
+
<span class='kw'>end</span>
|
|
823
|
+
<span class='kw'>nil</span>
|
|
824
|
+
<span class='kw'>end</span></pre>
|
|
825
|
+
</td>
|
|
826
|
+
</tr>
|
|
827
|
+
</table>
|
|
828
|
+
</div>
|
|
829
|
+
|
|
830
|
+
</div>
|
|
831
|
+
|
|
832
|
+
</div>
|
|
833
|
+
|
|
834
|
+
<div id="footer">
|
|
835
|
+
Generated on Mon Jun 15 19:57:57 2026 by
|
|
836
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
837
|
+
0.9.44 (ruby-4.0.5).
|
|
838
|
+
</div>
|
|
839
|
+
|
|
840
|
+
</div>
|
|
841
|
+
</body>
|
|
842
|
+
</html>
|