minting 1.3.0 → 1.4.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.
data/doc/Mint.html ADDED
@@ -0,0 +1,953 @@
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
8
+
9
+ &mdash; 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";
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 (M)</a> &raquo;
42
+
43
+
44
+ <span class="title">Mint</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
65
+
66
+
67
+
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/refinements.rb<span class="defines">,<br>
84
+ lib/minting/money/money.rb,<br> lib/minting/money/parse.rb,<br> lib/minting/mint/currency.rb,<br> lib/minting/mint/registry.rb,<br> lib/minting/money/coercion.rb,<br> lib/minting/money/allocation.rb,<br> lib/minting/money/comparable.rb,<br> lib/minting/money/conversion.rb,<br> lib/minting/money/formatting.rb,<br> lib/minting/money/arithmetics.rb</span>
85
+
86
+ </dd>
87
+ </dl>
88
+
89
+ </div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+ <p>Mint is a library to operate with monetary values</p>
94
+
95
+ </div>
96
+ </div>
97
+ <div class="tags">
98
+
99
+
100
+ </div><h2>Defined Under Namespace</h2>
101
+ <p class="children">
102
+
103
+
104
+
105
+
106
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span>, <span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span>
107
+
108
+
109
+ </p>
110
+
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> &#x21d2; Hash{String =&gt; Currency} </a>
129
+
130
+
131
+
132
+ </span>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <span class="summary_desc"><div class='inline'><p>Returns the hash of all registered currencies.</p></div></span>
143
+
144
+ </li>
145
+
146
+
147
+ <li class="public ">
148
+ <span class="summary_signature">
149
+
150
+ <a href="#currency-class_method" title="currency (class method)">.<strong>currency</strong>(currency) &#x21d2; Currency<sup>?</sup> </a>
151
+
152
+
153
+
154
+ </span>
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+ <span class="summary_desc"><div class='inline'><p>Finds a registered currency by its code, symbol, or retrieves it directly if already a Currency object.</p></div></span>
165
+
166
+ </li>
167
+
168
+
169
+ <li class="public ">
170
+ <span class="summary_signature">
171
+
172
+ <a href="#currency_symbols-class_method" title="currency_symbols (class method)">.<strong>currency_symbols</strong> &#x21d2; Object </a>
173
+
174
+
175
+
176
+ </span>
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+ <span class="summary_desc"><div class='inline'><p>Registered symbols sorted for detection: longest match wins, then parser priority.</p></div></span>
187
+
188
+ </li>
189
+
190
+
191
+ <li class="public ">
192
+ <span class="summary_signature">
193
+
194
+ <a href="#money-class_method" title="money (class method)">.<strong>money</strong>(amount, currency_code) &#x21d2; Money </a>
195
+
196
+
197
+
198
+ </span>
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+ <span class="summary_desc"><div class='inline'><p>Creates a new <span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span> instance with the given amount and currency code.</p></div></span>
209
+
210
+ </li>
211
+
212
+
213
+ <li class="public ">
214
+ <span class="summary_signature">
215
+
216
+ <a href="#register_currency-class_method" title="register_currency (class method)">.<strong>register_currency</strong>(code:, subunit: 2, symbol: &#39;&#39;, priority: 0) &#x21d2; Currency </a>
217
+
218
+
219
+
220
+ </span>
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+ <span class="summary_desc"><div class='inline'><p>Registers a new currency if not already registered.</p></div></span>
231
+
232
+ </li>
233
+
234
+
235
+ <li class="public ">
236
+ <span class="summary_signature">
237
+
238
+ <a href="#register_currency!-class_method" title="register_currency! (class method)">.<strong>register_currency!</strong>(code:, subunit:, symbol: &#39;&#39;, priority: 0) &#x21d2; Currency </a>
239
+
240
+
241
+
242
+ </span>
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+ <span class="summary_desc"><div class='inline'><p>Strictly registers a new currency, raising a KeyError if already registered.</p></div></span>
253
+
254
+ </li>
255
+
256
+
257
+ <li class="public ">
258
+ <span class="summary_signature">
259
+
260
+ <a href="#zero-class_method" title="zero (class method)">.<strong>zero</strong> &#x21d2; Object </a>
261
+
262
+
263
+
264
+ </span>
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+ <span class="summary_desc"><div class='inline'><p>Returns default zero, no currency money.</p></div></span>
275
+
276
+ </li>
277
+
278
+
279
+ </ul>
280
+
281
+
282
+
283
+
284
+
285
+ <div id="class_method_details" class="method_details_list">
286
+ <h2>Class Method Details</h2>
287
+
288
+
289
+ <div class="method_details first">
290
+ <h3 class="signature first" id="currencies-class_method">
291
+
292
+ .<strong>currencies</strong> &#x21d2; <tt>Hash{String =&gt; <span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>
293
+
294
+
295
+
296
+
297
+
298
+ </h3><div class="docstring">
299
+ <div class="discussion">
300
+ <p>Returns the hash of all registered currencies.</p>
301
+
302
+ </div>
303
+ </div>
304
+ <div class="tags">
305
+
306
+ <p class="tag_title">Returns:</p>
307
+ <ul class="return">
308
+
309
+ <li>
310
+
311
+
312
+ <span class='type'>(<tt>Hash{String =&gt; <span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span>}</tt>)</span>
313
+
314
+
315
+
316
+ &mdash;
317
+ <div class='inline'><p>registered currencies mapped by code</p></div>
318
+
319
+ </li>
320
+
321
+ </ul>
322
+
323
+ </div><table class="source_code">
324
+ <tr>
325
+ <td>
326
+ <pre class="lines">
327
+
328
+
329
+ 77
330
+ 78
331
+ 79
332
+ 80
333
+ 81
334
+ 82</pre>
335
+ </td>
336
+ <td>
337
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/registry.rb', line 77</span>
338
+
339
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_currencies'>currencies</span>
340
+ <span class='ivar'>@currencies</span> <span class='op'>||=</span> <span class='kw'>begin</span>
341
+ <span class='id identifier rubyid_registry'>registry</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>XXX</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='const'><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>code:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>XXX</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>No currency</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>symbol:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>¤</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
342
+ <span class='id identifier rubyid_load_currencies'>load_currencies</span><span class='lparen'>(</span><span class='id identifier rubyid_registry'>registry</span><span class='rparen'>)</span>
343
+ <span class='kw'>end</span>
344
+ <span class='kw'>end</span></pre>
345
+ </td>
346
+ </tr>
347
+ </table>
348
+ </div>
349
+
350
+ <div class="method_details ">
351
+ <h3 class="signature " id="currency-class_method">
352
+
353
+ .<strong>currency</strong>(currency) &#x21d2; <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
354
+
355
+
356
+
357
+
358
+
359
+ </h3><div class="docstring">
360
+ <div class="discussion">
361
+ <p>Finds a registered currency by its code, symbol,
362
+ or retrieves it directly if already a Currency object.</p>
363
+
364
+ </div>
365
+ </div>
366
+ <div class="tags">
367
+ <p class="tag_title">Parameters:</p>
368
+ <ul class="param">
369
+
370
+ <li>
371
+
372
+ <span class='name'>currency</span>
373
+
374
+
375
+ <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
376
+
377
+
378
+
379
+ &mdash;
380
+ <div class='inline'><p>the currency identifier or object</p></div>
381
+
382
+ </li>
383
+
384
+ </ul>
385
+
386
+ <p class="tag_title">Returns:</p>
387
+ <ul class="return">
388
+
389
+ <li>
390
+
391
+
392
+ <span class='type'>(<tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
393
+
394
+
395
+
396
+ &mdash;
397
+ <div class='inline'><p>the registered Currency instance or nil if not found</p></div>
398
+
399
+ </li>
400
+
401
+ </ul>
402
+
403
+ </div><table class="source_code">
404
+ <tr>
405
+ <td>
406
+ <pre class="lines">
407
+
408
+
409
+ 25
410
+ 26
411
+ 27
412
+ 28
413
+ 29
414
+ 30
415
+ 31
416
+ 32
417
+ 33
418
+ 34</pre>
419
+ </td>
420
+ <td>
421
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/registry.rb', line 25</span>
422
+
423
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_currency'>currency</span><span class='lparen'>(</span><span class='id identifier rubyid_currency'>currency</span><span class='rparen'>)</span>
424
+ <span class='kw'>case</span> <span class='id identifier rubyid_currency'>currency</span>
425
+ <span class='kw'>when</span> <span class='const'><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></span>
426
+ <span class='id identifier rubyid_currency'>currency</span>
427
+ <span class='kw'>when</span> <span class='const'>Symbol</span>
428
+ <span class='id identifier rubyid_currencies'>currencies</span><span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbracket'>]</span>
429
+ <span class='kw'>else</span>
430
+ <span class='id identifier rubyid_currencies'>currencies</span><span class='lbracket'>[</span><span class='id identifier rubyid_currency'>currency</span><span class='rbracket'>]</span>
431
+ <span class='kw'>end</span>
432
+ <span class='kw'>end</span></pre>
433
+ </td>
434
+ </tr>
435
+ </table>
436
+ </div>
437
+
438
+ <div class="method_details ">
439
+ <h3 class="signature " id="currency_symbols-class_method">
440
+
441
+ .<strong>currency_symbols</strong> &#x21d2; <tt>Object</tt>
442
+
443
+
444
+
445
+
446
+
447
+ </h3><div class="docstring">
448
+ <div class="discussion">
449
+ <p>Registered symbols sorted for detection: longest match wins, then parser priority.</p>
450
+
451
+ </div>
452
+ </div>
453
+ <div class="tags">
454
+
455
+
456
+ </div><table class="source_code">
457
+ <tr>
458
+ <td>
459
+ <pre class="lines">
460
+
461
+
462
+ 85
463
+ 86
464
+ 87
465
+ 88
466
+ 89
467
+ 90
468
+ 91
469
+ 92</pre>
470
+ </td>
471
+ <td>
472
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/registry.rb', line 85</span>
473
+
474
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_currency_symbols'>currency_symbols</span>
475
+ <span class='ivar'>@currency_symbols</span> <span class='op'>||=</span> <span class='kw'>begin</span>
476
+ <span class='id identifier rubyid_currencies'>currencies</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span>
477
+ <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>
478
+ <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_symbol'>symbol</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</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>
479
+ <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>
480
+ <span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
481
+ <span class='kw'>end</span></pre>
482
+ </td>
483
+ </tr>
484
+ </table>
485
+ </div>
486
+
487
+ <div class="method_details ">
488
+ <h3 class="signature " id="money-class_method">
489
+
490
+ .<strong>money</strong>(amount, currency_code) &#x21d2; <tt><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></tt>
491
+
492
+
493
+
494
+
495
+
496
+ </h3><div class="docstring">
497
+ <div class="discussion">
498
+ <p>Creates a new <span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span> instance with the given amount and currency code.</p>
499
+
500
+ </div>
501
+ </div>
502
+ <div class="tags">
503
+ <p class="tag_title">Parameters:</p>
504
+ <ul class="param">
505
+
506
+ <li>
507
+
508
+ <span class='name'>amount</span>
509
+
510
+
511
+ <span class='type'>(<tt>Numeric</tt>)</span>
512
+
513
+
514
+
515
+ &mdash;
516
+ <div class='inline'><p>the financial value</p></div>
517
+
518
+ </li>
519
+
520
+ <li>
521
+
522
+ <span class='name'>currency_code</span>
523
+
524
+
525
+ <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
526
+
527
+
528
+
529
+ &mdash;
530
+ <div class='inline'><p>the ISO currency code or symbol</p></div>
531
+
532
+ </li>
533
+
534
+ </ul>
535
+
536
+ <p class="tag_title">Returns:</p>
537
+ <ul class="return">
538
+
539
+ <li>
540
+
541
+
542
+ <span class='type'>(<tt><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></tt>)</span>
543
+
544
+
545
+
546
+ &mdash;
547
+ <div class='inline'><p>the instantiated Money object</p></div>
548
+
549
+ </li>
550
+
551
+ </ul>
552
+ <p class="tag_title">Raises:</p>
553
+ <ul class="raise">
554
+
555
+ <li>
556
+
557
+
558
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
559
+
560
+
561
+
562
+ &mdash;
563
+ <div class='inline'><p>if the currency code is not registered</p></div>
564
+
565
+ </li>
566
+
567
+ </ul>
568
+
569
+ </div><table class="source_code">
570
+ <tr>
571
+ <td>
572
+ <pre class="lines">
573
+
574
+
575
+ 10
576
+ 11
577
+ 12
578
+ 13
579
+ 14
580
+ 15</pre>
581
+ </td>
582
+ <td>
583
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/registry.rb', line 10</span>
584
+
585
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_money'>money</span><span class='lparen'>(</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='rparen'>)</span>
586
+ <span class='id identifier rubyid_currency'>currency</span> <span class='op'>=</span> <span class='id identifier rubyid_currency'>currency</span><span class='lparen'>(</span><span class='id identifier rubyid_currency_code'>currency_code</span><span class='rparen'>)</span>
587
+ <span class='kw'>return</span> <span class='const'><span class='object_link'><a href="Mint/Money.html" title="Mint::Money (class)">Money</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create'><span class='object_link'><a href="Mint/Money.html#create-class_method" title="Mint::Money.create (method)">create</a></span></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> <span class='kw'>if</span> <span class='id identifier rubyid_currency'>currency</span>
588
+
589
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_currency'>currency</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>] is not a registered currency. Check Mint.currencies</span><span class='tstring_end'>&quot;</span></span>
590
+ <span class='kw'>end</span></pre>
591
+ </td>
592
+ </tr>
593
+ </table>
594
+ </div>
595
+
596
+ <div class="method_details ">
597
+ <h3 class="signature " id="register_currency-class_method">
598
+
599
+ .<strong>register_currency</strong>(code:, subunit: 2, symbol: &#39;&#39;, priority: 0) &#x21d2; <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>
600
+
601
+
602
+
603
+
604
+
605
+ </h3><div class="docstring">
606
+ <div class="discussion">
607
+ <p>Registers a new currency if not already registered.</p>
608
+
609
+ </div>
610
+ </div>
611
+ <div class="tags">
612
+ <p class="tag_title">Parameters:</p>
613
+ <ul class="param">
614
+
615
+ <li>
616
+
617
+ <span class='name'>code</span>
618
+
619
+
620
+ <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
621
+
622
+
623
+
624
+ &mdash;
625
+ <div class='inline'><p>the unique currency code (e.g. 'USD', :EUR)</p></div>
626
+
627
+ </li>
628
+
629
+ <li>
630
+
631
+ <span class='name'>subunit</span>
632
+
633
+
634
+ <span class='type'>(<tt>Integer</tt>)</span>
635
+
636
+
637
+ <em class="default">(defaults to: <tt>2</tt>)</em>
638
+
639
+
640
+ &mdash;
641
+ <div class='inline'><p>the decimal subunit precision (defaults to 2)</p></div>
642
+
643
+ </li>
644
+
645
+ <li>
646
+
647
+ <span class='name'>symbol</span>
648
+
649
+
650
+ <span class='type'>(<tt>String</tt>)</span>
651
+
652
+
653
+ <em class="default">(defaults to: <tt>&#39;&#39;</tt>)</em>
654
+
655
+
656
+ &mdash;
657
+ <div class='inline'><p>the display symbol (defaults to '')</p></div>
658
+
659
+ </li>
660
+
661
+ <li>
662
+
663
+ <span class='name'>priority</span>
664
+
665
+
666
+ <span class='type'>(<tt>Integer</tt>)</span>
667
+
668
+
669
+ <em class="default">(defaults to: <tt>0</tt>)</em>
670
+
671
+
672
+ &mdash;
673
+ <div class='inline'><p>parser precedence priority (defaults to 0)</p></div>
674
+
675
+ </li>
676
+
677
+ </ul>
678
+
679
+ <p class="tag_title">Returns:</p>
680
+ <ul class="return">
681
+
682
+ <li>
683
+
684
+
685
+ <span class='type'>(<tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
686
+
687
+
688
+
689
+ &mdash;
690
+ <div class='inline'><p>the registered or existing Currency instance</p></div>
691
+
692
+ </li>
693
+
694
+ </ul>
695
+ <p class="tag_title">Raises:</p>
696
+ <ul class="raise">
697
+
698
+ <li>
699
+
700
+
701
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
702
+
703
+
704
+
705
+ &mdash;
706
+ <div class='inline'><p>if the code layout is invalid or register throws an error</p></div>
707
+
708
+ </li>
709
+
710
+ </ul>
711
+
712
+ </div><table class="source_code">
713
+ <tr>
714
+ <td>
715
+ <pre class="lines">
716
+
717
+
718
+ 44
719
+ 45
720
+ 46
721
+ 47</pre>
722
+ </td>
723
+ <td>
724
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/registry.rb', line 44</span>
725
+
726
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_register_currency'>register_currency</span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>subunit:</span> <span class='int'>2</span><span class='comma'>,</span> <span class='label'>symbol:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='rparen'>)</span>
727
+ <span class='id identifier rubyid_code'>code</span> <span class='op'>=</span> <span class='id identifier rubyid_code'>code</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
728
+ <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='id identifier rubyid_register_currency!'>register_currency!</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>
729
+ <span class='kw'>end</span></pre>
730
+ </td>
731
+ </tr>
732
+ </table>
733
+ </div>
734
+
735
+ <div class="method_details ">
736
+ <h3 class="signature " id="register_currency!-class_method">
737
+
738
+ .<strong>register_currency!</strong>(code:, subunit:, symbol: &#39;&#39;, priority: 0) &#x21d2; <tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>
739
+
740
+
741
+
742
+
743
+
744
+ </h3><div class="docstring">
745
+ <div class="discussion">
746
+ <p>Strictly registers a new currency, raising a KeyError if already registered.</p>
747
+
748
+ </div>
749
+ </div>
750
+ <div class="tags">
751
+ <p class="tag_title">Parameters:</p>
752
+ <ul class="param">
753
+
754
+ <li>
755
+
756
+ <span class='name'>code</span>
757
+
758
+
759
+ <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
760
+
761
+
762
+
763
+ &mdash;
764
+ <div class='inline'><p>the unique currency code</p></div>
765
+
766
+ </li>
767
+
768
+ <li>
769
+
770
+ <span class='name'>subunit</span>
771
+
772
+
773
+ <span class='type'>(<tt>Integer</tt>)</span>
774
+
775
+
776
+
777
+ &mdash;
778
+ <div class='inline'><p>the decimal subunit precision</p></div>
779
+
780
+ </li>
781
+
782
+ <li>
783
+
784
+ <span class='name'>symbol</span>
785
+
786
+
787
+ <span class='type'>(<tt>String</tt>)</span>
788
+
789
+
790
+ <em class="default">(defaults to: <tt>&#39;&#39;</tt>)</em>
791
+
792
+
793
+ &mdash;
794
+ <div class='inline'><p>the display symbol</p></div>
795
+
796
+ </li>
797
+
798
+ <li>
799
+
800
+ <span class='name'>priority</span>
801
+
802
+
803
+ <span class='type'>(<tt>Integer</tt>)</span>
804
+
805
+
806
+ <em class="default">(defaults to: <tt>0</tt>)</em>
807
+
808
+
809
+ &mdash;
810
+ <div class='inline'><p>parser precedence priority</p></div>
811
+
812
+ </li>
813
+
814
+ </ul>
815
+
816
+ <p class="tag_title">Returns:</p>
817
+ <ul class="return">
818
+
819
+ <li>
820
+
821
+
822
+ <span class='type'>(<tt><span class='object_link'><a href="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
823
+
824
+
825
+
826
+ &mdash;
827
+ <div class='inline'><p>the newly registered Currency instance</p></div>
828
+
829
+ </li>
830
+
831
+ </ul>
832
+ <p class="tag_title">Raises:</p>
833
+ <ul class="raise">
834
+
835
+ <li>
836
+
837
+
838
+ <span class='type'>(<tt>ArgumentError</tt>)</span>
839
+
840
+
841
+
842
+ &mdash;
843
+ <div class='inline'><p>if the code contains invalid characters</p></div>
844
+
845
+ </li>
846
+
847
+ <li>
848
+
849
+
850
+ <span class='type'>(<tt>KeyError</tt>)</span>
851
+
852
+
853
+
854
+ &mdash;
855
+ <div class='inline'><p>if the currency code is already registered</p></div>
856
+
857
+ </li>
858
+
859
+ </ul>
860
+
861
+ </div><table class="source_code">
862
+ <tr>
863
+ <td>
864
+ <pre class="lines">
865
+
866
+
867
+ 58
868
+ 59
869
+ 60
870
+ 61
871
+ 62
872
+ 63
873
+ 64
874
+ 65
875
+ 66
876
+ 67
877
+ 68
878
+ 69
879
+ 70
880
+ 71
881
+ 72</pre>
882
+ </td>
883
+ <td>
884
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/registry.rb', line 58</span>
885
+
886
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_register_currency!'>register_currency!</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='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='rparen'>)</span>
887
+ <span class='id identifier rubyid_code'>code</span> <span class='op'>=</span> <span class='id identifier rubyid_code'>code</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
888
+ <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>
889
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span>
890
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Currency code must be String or Symbol (&#39;USD&#39;, :EUR, &#39;FUEL&#39;, &#39;MY_COIN&#39;)</span><span class='tstring_end'>&quot;</span></span>
891
+ <span class='kw'>end</span>
892
+ <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>
893
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>KeyError</span><span class='comma'>,</span>
894
+ <span class='tstring'><span class='tstring_beg'>&quot;</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'>&quot;</span></span>
895
+ <span class='kw'>end</span>
896
+
897
+ <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="Mint/Currency.html" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</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>
898
+ <span class='ivar'>@currency_symbols</span> <span class='op'>=</span> <span class='kw'>nil</span>
899
+ <span class='id identifier rubyid_currency'>currency</span>
900
+ <span class='kw'>end</span></pre>
901
+ </td>
902
+ </tr>
903
+ </table>
904
+ </div>
905
+
906
+ <div class="method_details ">
907
+ <h3 class="signature " id="zero-class_method">
908
+
909
+ .<strong>zero</strong> &#x21d2; <tt>Object</tt>
910
+
911
+
912
+
913
+
914
+
915
+ </h3><div class="docstring">
916
+ <div class="discussion">
917
+ <p>Returns default zero, no currency money</p>
918
+
919
+ </div>
920
+ </div>
921
+ <div class="tags">
922
+
923
+
924
+ </div><table class="source_code">
925
+ <tr>
926
+ <td>
927
+ <pre class="lines">
928
+
929
+
930
+ 18</pre>
931
+ </td>
932
+ <td>
933
+ <pre class="code"><span class="info file"># File 'lib/minting/mint/registry.rb', line 18</span>
934
+
935
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_zero'>zero</span> <span class='op'>=</span> <span class='ivar'>@zero</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="Mint/Money.html" 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='int'>0</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="" title="Mint (module)">Mint</a></span></span><span class='period'>.</span><span class='id identifier rubyid_currency'><span class='object_link'><a href="#currency-class_method" title="Mint.currency (method)">currency</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>XXX</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span></pre>
936
+ </td>
937
+ </tr>
938
+ </table>
939
+ </div>
940
+
941
+ </div>
942
+
943
+ </div>
944
+
945
+ <div id="footer">
946
+ Generated on Tue Jun 2 14:44:35 2026 by
947
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
948
+ 0.9.44 (ruby-4.0.1).
949
+ </div>
950
+
951
+ </div>
952
+ </body>
953
+ </html>