minting 1.6.3 → 1.7.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 +7 -2
- data/Rakefile +13 -3
- data/doc/Mint/Currency.html +993 -0
- data/doc/Mint/CurrencyRegistry.html +511 -0
- data/doc/Mint/Money.html +3856 -0
- data/doc/Mint/UnknownCurrency.html +136 -0
- data/doc/Mint.html +886 -0
- data/doc/Minting.html +142 -0
- data/doc/_index.html +158 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +206 -0
- data/doc/css/style.css +1089 -0
- data/doc/file.README.html +278 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +22 -0
- data/doc/index.html +278 -0
- data/doc/js/app.js +801 -0
- data/doc/js/full_list.js +334 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +510 -0
- data/doc/top-level-namespace.html +143 -0
- data/lib/minting/mint/currency/currency_registry.rb +1 -1
- data/lib/minting/mint/dsl/range.rb +54 -0
- data/lib/minting/mint/{dsl.rb → dsl/refinements.rb} +0 -10
- data/lib/minting/mint/dsl/top_level.rb +14 -0
- data/lib/minting/mint/mint.rb +2 -2
- data/lib/minting/mint/parser.rb +16 -9
- data/lib/minting/mint.rb +3 -1
- data/lib/minting/money/allocation.rb +14 -14
- data/lib/minting/money/arithmetics.rb +5 -5
- data/lib/minting/money/coercion.rb +8 -11
- data/lib/minting/money/formatting.rb +23 -28
- data/lib/minting/version.rb +1 -1
- data/minting.gemspec +5 -2
- metadata +31 -5
|
@@ -0,0 +1,511 @@
|
|
|
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::CurrencyRegistry
|
|
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::CurrencyRegistry";
|
|
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 (C)</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">CurrencyRegistry</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::CurrencyRegistry
|
|
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::CurrencyRegistry (module)">CurrencyRegistry</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::CurrencyRegistry (module)">CurrencyRegistry</a></span></dd>
|
|
87
|
+
</dl>
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
<dl>
|
|
92
|
+
<dt>Defined in:</dt>
|
|
93
|
+
<dd>lib/minting/mint/currency/currency_registry.rb
|
|
94
|
+
</dd>
|
|
95
|
+
</dl>
|
|
96
|
+
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<h2>Overview</h2><div class="docstring">
|
|
100
|
+
<div class="discussion">
|
|
101
|
+
<p>Internal currency registry
|
|
102
|
+
Manages the registry cache and currency symbol lookups.</p>
|
|
103
|
+
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
<div class="tags">
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
<h2>
|
|
118
|
+
Instance Method Summary
|
|
119
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
120
|
+
</h2>
|
|
121
|
+
|
|
122
|
+
<ul class="summary">
|
|
123
|
+
|
|
124
|
+
<li class="public ">
|
|
125
|
+
<span class="summary_signature">
|
|
126
|
+
|
|
127
|
+
<a href="#currencies-instance_method" title="#currencies (instance method)">#<strong>currencies</strong> ⇒ Hash{String => Currency} </a>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
</span>
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
<span class="private note title">private</span>
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
<span class="summary_desc"><div class='inline'><p>Returns the hash of all registered currencies.</p></div></span>
|
|
142
|
+
|
|
143
|
+
</li>
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
<li class="public ">
|
|
147
|
+
<span class="summary_signature">
|
|
148
|
+
|
|
149
|
+
<a href="#currency_symbols-instance_method" title="#currency_symbols (instance method)">#<strong>currency_symbols</strong> ⇒ Array<Array<String, Currency>> </a>
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
</span>
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
<span class="private note title">private</span>
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
<span class="summary_desc"><div class='inline'><p>Registered symbols sorted for detection: longest match wins, then parser priority.</p></div></span>
|
|
164
|
+
|
|
165
|
+
</li>
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
<li class="public ">
|
|
169
|
+
<span class="summary_signature">
|
|
170
|
+
|
|
171
|
+
<a href="#register-instance_method" title="#register (instance method)">#<strong>register</strong>(code:, subunit: 0, symbol: '', priority: 0) ⇒ Currency </a>
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
</span>
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
<span class="summary_desc"><div class='inline'><p>Registers a new currency, raising a KeyError if already registered.</p></div></span>
|
|
186
|
+
|
|
187
|
+
</li>
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
</ul>
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
<div id="instance_method_details" class="method_details_list">
|
|
197
|
+
<h2>Instance Method Details</h2>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
<div class="method_details first">
|
|
201
|
+
<h3 class="signature first" id="currencies-instance_method">
|
|
202
|
+
|
|
203
|
+
#<strong>currencies</strong> ⇒ <tt>Hash{String => <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
</h3><div class="docstring">
|
|
210
|
+
<div class="discussion">
|
|
211
|
+
<p class="note private">
|
|
212
|
+
<strong>This method is part of a private API.</strong>
|
|
213
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
214
|
+
</p>
|
|
215
|
+
<p>Returns the hash of all registered currencies.</p>
|
|
216
|
+
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
<div class="tags">
|
|
220
|
+
|
|
221
|
+
<p class="tag_title">Returns:</p>
|
|
222
|
+
<ul class="return">
|
|
223
|
+
|
|
224
|
+
<li>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
<span class='type'>(<tt>Hash{String => <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>)</span>
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
—
|
|
232
|
+
<div class='inline'><p>registered currencies mapped by code</p></div>
|
|
233
|
+
|
|
234
|
+
</li>
|
|
235
|
+
|
|
236
|
+
</ul>
|
|
237
|
+
|
|
238
|
+
</div><table class="source_code">
|
|
239
|
+
<tr>
|
|
240
|
+
<td>
|
|
241
|
+
<pre class="lines">
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
16
|
|
245
|
+
17
|
|
246
|
+
18</pre>
|
|
247
|
+
</td>
|
|
248
|
+
<td>
|
|
249
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/currency/currency_registry.rb', line 16</span>
|
|
250
|
+
|
|
251
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_currencies'>currencies</span>
|
|
252
|
+
<span class='ivar'>@currencies</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_world_currencies'><span class='object_link'><a href="../Mint.html#world_currencies-class_method" title="Mint.world_currencies (method)">world_currencies</a></span></span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span>
|
|
253
|
+
<span class='kw'>end</span></pre>
|
|
254
|
+
</td>
|
|
255
|
+
</tr>
|
|
256
|
+
</table>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div class="method_details ">
|
|
260
|
+
<h3 class="signature " id="currency_symbols-instance_method">
|
|
261
|
+
|
|
262
|
+
#<strong>currency_symbols</strong> ⇒ <tt>Array<Array<String, <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>>></tt>
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
</h3><div class="docstring">
|
|
269
|
+
<div class="discussion">
|
|
270
|
+
<p class="note private">
|
|
271
|
+
<strong>This method is part of a private API.</strong>
|
|
272
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
273
|
+
</p>
|
|
274
|
+
<p>Registered symbols sorted for detection: longest match wins, then parser priority.</p>
|
|
275
|
+
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
<div class="tags">
|
|
279
|
+
|
|
280
|
+
<p class="tag_title">Returns:</p>
|
|
281
|
+
<ul class="return">
|
|
282
|
+
|
|
283
|
+
<li>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
<span class='type'>(<tt>Array<Array<String, <span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span>>></tt>)</span>
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
—
|
|
291
|
+
<div class='inline'><p>sorted symbol-to-currency mappings</p></div>
|
|
292
|
+
|
|
293
|
+
</li>
|
|
294
|
+
|
|
295
|
+
</ul>
|
|
296
|
+
|
|
297
|
+
</div><table class="source_code">
|
|
298
|
+
<tr>
|
|
299
|
+
<td>
|
|
300
|
+
<pre class="lines">
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
24
|
|
304
|
+
25
|
|
305
|
+
26
|
|
306
|
+
27
|
|
307
|
+
28
|
|
308
|
+
29
|
|
309
|
+
30
|
|
310
|
+
31</pre>
|
|
311
|
+
</td>
|
|
312
|
+
<td>
|
|
313
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/currency/currency_registry.rb', line 24</span>
|
|
314
|
+
|
|
315
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_currency_symbols'>currency_symbols</span>
|
|
316
|
+
<span class='ivar'>@currency_symbols</span> <span class='op'>||=</span> <span class='kw'>begin</span>
|
|
317
|
+
<span class='id identifier rubyid_currencies'>currencies</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span>
|
|
318
|
+
<span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_currency'>currency</span><span class='op'>|</span> <span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_symbol'>symbol</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='rbrace'>}</span>
|
|
319
|
+
<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_currency'>currency</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='id identifier rubyid_currency'>currency</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
|
|
320
|
+
<span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span> <span class='lbrace'>{</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> <span class='lbracket'>[</span><span class='op'>-</span><span class='id identifier rubyid_symbol'>symbol</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='comma'>,</span> <span class='op'>-</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_priority'>priority</span><span class='rbracket'>]</span> <span class='rbrace'>}</span>
|
|
321
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
|
322
|
+
<span class='kw'>end</span></pre>
|
|
323
|
+
</td>
|
|
324
|
+
</tr>
|
|
325
|
+
</table>
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
<div class="method_details ">
|
|
329
|
+
<h3 class="signature " id="register-instance_method">
|
|
330
|
+
|
|
331
|
+
#<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>
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
</h3><div class="docstring">
|
|
338
|
+
<div class="discussion">
|
|
339
|
+
<p>Registers a new currency, raising a KeyError if already registered.</p>
|
|
340
|
+
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
<div class="tags">
|
|
344
|
+
<p class="tag_title">Parameters:</p>
|
|
345
|
+
<ul class="param">
|
|
346
|
+
|
|
347
|
+
<li>
|
|
348
|
+
|
|
349
|
+
<span class='name'>code</span>
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
—
|
|
357
|
+
<div class='inline'><p>the unique currency code</p></div>
|
|
358
|
+
|
|
359
|
+
</li>
|
|
360
|
+
|
|
361
|
+
<li>
|
|
362
|
+
|
|
363
|
+
<span class='name'>subunit</span>
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
—
|
|
373
|
+
<div class='inline'><p>the decimal subunit precision, defaults to 0</p></div>
|
|
374
|
+
|
|
375
|
+
</li>
|
|
376
|
+
|
|
377
|
+
<li>
|
|
378
|
+
|
|
379
|
+
<span class='name'>symbol</span>
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
<em class="default">(defaults to: <tt>''</tt>)</em>
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
—
|
|
389
|
+
<div class='inline'><p>the display symbol</p></div>
|
|
390
|
+
|
|
391
|
+
</li>
|
|
392
|
+
|
|
393
|
+
<li>
|
|
394
|
+
|
|
395
|
+
<span class='name'>priority</span>
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
—
|
|
405
|
+
<div class='inline'><p>parser precedence priority</p></div>
|
|
406
|
+
|
|
407
|
+
</li>
|
|
408
|
+
|
|
409
|
+
</ul>
|
|
410
|
+
|
|
411
|
+
<p class="tag_title">Returns:</p>
|
|
412
|
+
<ul class="return">
|
|
413
|
+
|
|
414
|
+
<li>
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
<span class='type'>(<tt><span class='object_link'><a href="Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
—
|
|
422
|
+
<div class='inline'><p>the newly registered Currency instance</p></div>
|
|
423
|
+
|
|
424
|
+
</li>
|
|
425
|
+
|
|
426
|
+
</ul>
|
|
427
|
+
<p class="tag_title">Raises:</p>
|
|
428
|
+
<ul class="raise">
|
|
429
|
+
|
|
430
|
+
<li>
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
—
|
|
438
|
+
<div class='inline'><p>if the code contains invalid characters</p></div>
|
|
439
|
+
|
|
440
|
+
</li>
|
|
441
|
+
|
|
442
|
+
<li>
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
<span class='type'>(<tt>KeyError</tt>)</span>
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
—
|
|
450
|
+
<div class='inline'><p>if the currency code is already registered</p></div>
|
|
451
|
+
|
|
452
|
+
</li>
|
|
453
|
+
|
|
454
|
+
</ul>
|
|
455
|
+
|
|
456
|
+
</div><table class="source_code">
|
|
457
|
+
<tr>
|
|
458
|
+
<td>
|
|
459
|
+
<pre class="lines">
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
42
|
|
463
|
+
43
|
|
464
|
+
44
|
|
465
|
+
45
|
|
466
|
+
46
|
|
467
|
+
47
|
|
468
|
+
48
|
|
469
|
+
49
|
|
470
|
+
50
|
|
471
|
+
51
|
|
472
|
+
52
|
|
473
|
+
53
|
|
474
|
+
54
|
|
475
|
+
55</pre>
|
|
476
|
+
</td>
|
|
477
|
+
<td>
|
|
478
|
+
<pre class="code"><span class="info file"># File 'lib/minting/mint/currency/currency_registry.rb', line 42</span>
|
|
479
|
+
|
|
480
|
+
<span class='kw'>def</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>
|
|
481
|
+
<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>
|
|
482
|
+
<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>
|
|
483
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span>
|
|
484
|
+
<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>
|
|
485
|
+
<span class='kw'>end</span>
|
|
486
|
+
|
|
487
|
+
<span class='id identifier rubyid_currencies'>currencies</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="Mint::CurrencyRegistry (module)">CurrencyRegistry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_currencies'><span class='object_link'><a href="#currencies-instance_method" title="Mint::CurrencyRegistry#currencies (method)">currencies</a></span></span>
|
|
488
|
+
<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>
|
|
489
|
+
|
|
490
|
+
<span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</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> <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>
|
|
491
|
+
<span class='id identifier rubyid_invalidate_symbols_cache'>invalidate_symbols_cache</span>
|
|
492
|
+
<span class='id identifier rubyid_currency'>currency</span>
|
|
493
|
+
<span class='kw'>end</span></pre>
|
|
494
|
+
</td>
|
|
495
|
+
</tr>
|
|
496
|
+
</table>
|
|
497
|
+
</div>
|
|
498
|
+
|
|
499
|
+
</div>
|
|
500
|
+
|
|
501
|
+
</div>
|
|
502
|
+
|
|
503
|
+
<div id="footer">
|
|
504
|
+
Generated on Wed Jun 10 01:35:30 2026 by
|
|
505
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
506
|
+
0.9.44 (ruby-4.0.1).
|
|
507
|
+
</div>
|
|
508
|
+
|
|
509
|
+
</div>
|
|
510
|
+
</body>
|
|
511
|
+
</html>
|