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.
@@ -0,0 +1,470 @@
1
+ <!DOCTYPE html>
2
+ <html >
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <meta charset="utf-8">
6
+
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen">
8
+
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen">
10
+
11
+
12
+
13
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
14
+
15
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
16
+
17
+
18
+ <title>Method List</title>
19
+ <base id="base_target" target="_parent">
20
+ </head>
21
+ <body>
22
+ <div id="content">
23
+ <div class="fixed_header">
24
+ <h1 id="full_list_header">Method List</h1>
25
+ <div id="full_list_nav">
26
+
27
+ <span><a target="_self" href="class_list.html">
28
+ Classes
29
+ </a></span>
30
+
31
+ <span><a target="_self" href="method_list.html">
32
+ Methods
33
+ </a></span>
34
+
35
+ <span><a target="_self" href="file_list.html">
36
+ Files
37
+ </a></span>
38
+
39
+ </div>
40
+
41
+ <div id="search">
42
+ <label for="search-class">Search:</label>
43
+ <input id="search-class" type="text">
44
+ </div>
45
+ </div>
46
+
47
+ <ul id="full_list" class="method">
48
+
49
+
50
+ <li class="odd ">
51
+ <div class="item">
52
+ <span class='object_link'><a href="Mint/Money.html#*-instance_method" title="Mint::Money#* (method)">#*</a></span>
53
+ <small>Mint::Money</small>
54
+ </div>
55
+ </li>
56
+
57
+
58
+ <li class="even ">
59
+ <div class="item">
60
+ <span class='object_link'><a href="Mint/Money.html#%2B-instance_method" title="Mint::Money#+ (method)">#+</a></span>
61
+ <small>Mint::Money</small>
62
+ </div>
63
+ </li>
64
+
65
+
66
+ <li class="odd ">
67
+ <div class="item">
68
+ <span class='object_link'><a href="Mint/Money.html#--instance_method" title="Mint::Money#- (method)">#-</a></span>
69
+ <small>Mint::Money</small>
70
+ </div>
71
+ </li>
72
+
73
+
74
+ <li class="even ">
75
+ <div class="item">
76
+ <span class='object_link'><a href="Mint/Money.html#-@-instance_method" title="Mint::Money#-@ (method)">#-@</a></span>
77
+ <small>Mint::Money</small>
78
+ </div>
79
+ </li>
80
+
81
+
82
+ <li class="odd ">
83
+ <div class="item">
84
+ <span class='object_link'><a href="Mint/Money.html#%2F-instance_method" title="Mint::Money#/ (method)">#/</a></span>
85
+ <small>Mint::Money</small>
86
+ </div>
87
+ </li>
88
+
89
+
90
+ <li class="even ">
91
+ <div class="item">
92
+ <span class='object_link'><a href="Mint/Money.html#<=>-instance_method" title="Mint::Money#&lt;=&gt; (method)">#&lt;=&gt;</a></span>
93
+ <small>Mint::Money</small>
94
+ </div>
95
+ </li>
96
+
97
+
98
+ <li class="odd ">
99
+ <div class="item">
100
+ <span class='object_link'><a href="Mint/Money.html#==-instance_method" title="Mint::Money#== (method)">#==</a></span>
101
+ <small>Mint::Money</small>
102
+ </div>
103
+ </li>
104
+
105
+
106
+ <li class="even ">
107
+ <div class="item">
108
+ <span class='object_link'><a href="Mint/Money.html#abs-instance_method" title="Mint::Money#abs (method)">#abs</a></span>
109
+ <small>Mint::Money</small>
110
+ </div>
111
+ </li>
112
+
113
+
114
+ <li class="odd ">
115
+ <div class="item">
116
+ <span class='object_link'><a href="Mint/Money.html#allocate-instance_method" title="Mint::Money#allocate (method)">#allocate</a></span>
117
+ <small>Mint::Money</small>
118
+ </div>
119
+ </li>
120
+
121
+
122
+ <li class="even ">
123
+ <div class="item">
124
+ <span class='object_link'><a href="Mint/Money.html#amount-instance_method" title="Mint::Money#amount (method)">#amount</a></span>
125
+ <small>Mint::Money</small>
126
+ </div>
127
+ </li>
128
+
129
+
130
+ <li class="odd ">
131
+ <div class="item">
132
+ <span class='object_link'><a href="Mint/Currency.html#code-instance_method" title="Mint::Currency#code (method)">#code</a></span>
133
+ <small>Mint::Currency</small>
134
+ </div>
135
+ </li>
136
+
137
+
138
+ <li class="even ">
139
+ <div class="item">
140
+ <span class='object_link'><a href="Mint/Money.html#coerce-instance_method" title="Mint::Money#coerce (method)">#coerce</a></span>
141
+ <small>Mint::Money</small>
142
+ </div>
143
+ </li>
144
+
145
+
146
+ <li class="odd ">
147
+ <div class="item">
148
+ <span class='object_link'><a href="Mint/Currency.html#country-instance_method" title="Mint::Currency#country (method)">#country</a></span>
149
+ <small>Mint::Currency</small>
150
+ </div>
151
+ </li>
152
+
153
+
154
+ <li class="even ">
155
+ <div class="item">
156
+ <span class='object_link'><a href="Mint/Money.html#create-class_method" title="Mint::Money.create (method)">create</a></span>
157
+ <small>Mint::Money</small>
158
+ </div>
159
+ </li>
160
+
161
+
162
+ <li class="odd ">
163
+ <div class="item">
164
+ <span class='object_link'><a href="Mint.html#currencies-class_method" title="Mint.currencies (method)">currencies</a></span>
165
+ <small>Mint</small>
166
+ </div>
167
+ </li>
168
+
169
+
170
+ <li class="even ">
171
+ <div class="item">
172
+ <span class='object_link'><a href="Mint.html#currency-class_method" title="Mint.currency (method)">currency</a></span>
173
+ <small>Mint</small>
174
+ </div>
175
+ </li>
176
+
177
+
178
+ <li class="odd ">
179
+ <div class="item">
180
+ <span class='object_link'><a href="Mint/Money.html#currency-instance_method" title="Mint::Money#currency (method)">#currency</a></span>
181
+ <small>Mint::Money</small>
182
+ </div>
183
+ </li>
184
+
185
+
186
+ <li class="even ">
187
+ <div class="item">
188
+ <span class='object_link'><a href="Mint/Money.html#currency_code-instance_method" title="Mint::Money#currency_code (method)">#currency_code</a></span>
189
+ <small>Mint::Money</small>
190
+ </div>
191
+ </li>
192
+
193
+
194
+ <li class="odd ">
195
+ <div class="item">
196
+ <span class='object_link'><a href="Mint.html#currency_symbols-class_method" title="Mint.currency_symbols (method)">currency_symbols</a></span>
197
+ <small>Mint</small>
198
+ </div>
199
+ </li>
200
+
201
+
202
+ <li class="even ">
203
+ <div class="item">
204
+ <span class='object_link'><a href="Mint/Money.html#eql%3F-instance_method" title="Mint::Money#eql? (method)">#eql?</a></span>
205
+ <small>Mint::Money</small>
206
+ </div>
207
+ </li>
208
+
209
+
210
+ <li class="odd ">
211
+ <div class="item">
212
+ <span class='object_link'><a href="Mint/Money.html#fractional-instance_method" title="Mint::Money#fractional (method)">#fractional</a></span>
213
+ <small>Mint::Money</small>
214
+ </div>
215
+ </li>
216
+
217
+
218
+ <li class="even ">
219
+ <div class="item">
220
+ <span class='object_link'><a href="Mint/Currency.html#fractional_multiplier-instance_method" title="Mint::Currency#fractional_multiplier (method)">#fractional_multiplier</a></span>
221
+ <small>Mint::Currency</small>
222
+ </div>
223
+ </li>
224
+
225
+
226
+ <li class="odd ">
227
+ <div class="item">
228
+ <span class='object_link'><a href="Mint/Money.html#hash-instance_method" title="Mint::Money#hash (method)">#hash</a></span>
229
+ <small>Mint::Money</small>
230
+ </div>
231
+ </li>
232
+
233
+
234
+ <li class="even ">
235
+ <div class="item">
236
+ <span class='object_link'><a href="Mint/Currency.html#inspect-instance_method" title="Mint::Currency#inspect (method)">#inspect</a></span>
237
+ <small>Mint::Currency</small>
238
+ </div>
239
+ </li>
240
+
241
+
242
+ <li class="odd ">
243
+ <div class="item">
244
+ <span class='object_link'><a href="Mint/Money.html#inspect-instance_method" title="Mint::Money#inspect (method)">#inspect</a></span>
245
+ <small>Mint::Money</small>
246
+ </div>
247
+ </li>
248
+
249
+
250
+ <li class="even ">
251
+ <div class="item">
252
+ <span class='object_link'><a href="Mint/Currency.html#minimum_amount-instance_method" title="Mint::Currency#minimum_amount (method)">#minimum_amount</a></span>
253
+ <small>Mint::Currency</small>
254
+ </div>
255
+ </li>
256
+
257
+
258
+ <li class="odd ">
259
+ <div class="item">
260
+ <span class='object_link'><a href="Mint/Money.html#mint-instance_method" title="Mint::Money#mint (method)">#mint</a></span>
261
+ <small>Mint::Money</small>
262
+ </div>
263
+ </li>
264
+
265
+
266
+ <li class="even ">
267
+ <div class="item">
268
+ <span class='object_link'><a href="Mint.html#money-class_method" title="Mint.money (method)">money</a></span>
269
+ <small>Mint</small>
270
+ </div>
271
+ </li>
272
+
273
+
274
+ <li class="odd ">
275
+ <div class="item">
276
+ <span class='object_link'><a href="Mint/Currency.html#name-instance_method" title="Mint::Currency#name (method)">#name</a></span>
277
+ <small>Mint::Currency</small>
278
+ </div>
279
+ </li>
280
+
281
+
282
+ <li class="even ">
283
+ <div class="item">
284
+ <span class='object_link'><a href="Mint/Money.html#negative%3F-instance_method" title="Mint::Money#negative? (method)">#negative?</a></span>
285
+ <small>Mint::Money</small>
286
+ </div>
287
+ </li>
288
+
289
+
290
+ <li class="odd ">
291
+ <div class="item">
292
+ <span class='object_link'><a href="Mint/Money.html#nonzero%3F-instance_method" title="Mint::Money#nonzero? (method)">#nonzero?</a></span>
293
+ <small>Mint::Money</small>
294
+ </div>
295
+ </li>
296
+
297
+
298
+ <li class="even ">
299
+ <div class="item">
300
+ <span class='object_link'><a href="Mint/Currency.html#normalize_amount-instance_method" title="Mint::Currency#normalize_amount (method)">#normalize_amount</a></span>
301
+ <small>Mint::Currency</small>
302
+ </div>
303
+ </li>
304
+
305
+
306
+ <li class="odd ">
307
+ <div class="item">
308
+ <span class='object_link'><a href="Mint/Money.html#parse-class_method" title="Mint::Money.parse (method)">parse</a></span>
309
+ <small>Mint::Money</small>
310
+ </div>
311
+ </li>
312
+
313
+
314
+ <li class="even ">
315
+ <div class="item">
316
+ <span class='object_link'><a href="Mint/Money.html#positive%3F-instance_method" title="Mint::Money#positive? (method)">#positive?</a></span>
317
+ <small>Mint::Money</small>
318
+ </div>
319
+ </li>
320
+
321
+
322
+ <li class="odd ">
323
+ <div class="item">
324
+ <span class='object_link'><a href="Mint/Currency.html#priority-instance_method" title="Mint::Currency#priority (method)">#priority</a></span>
325
+ <small>Mint::Currency</small>
326
+ </div>
327
+ </li>
328
+
329
+
330
+ <li class="even ">
331
+ <div class="item">
332
+ <span class='object_link'><a href="Mint.html#register_currency-class_method" title="Mint.register_currency (method)">register_currency</a></span>
333
+ <small>Mint</small>
334
+ </div>
335
+ </li>
336
+
337
+
338
+ <li class="odd ">
339
+ <div class="item">
340
+ <span class='object_link'><a href="Mint.html#register_currency!-class_method" title="Mint.register_currency! (method)">register_currency!</a></span>
341
+ <small>Mint</small>
342
+ </div>
343
+ </li>
344
+
345
+
346
+ <li class="even ">
347
+ <div class="item">
348
+ <span class='object_link'><a href="Mint/Money.html#same_currency%3F-instance_method" title="Mint::Money#same_currency? (method)">#same_currency?</a></span>
349
+ <small>Mint::Money</small>
350
+ </div>
351
+ </li>
352
+
353
+
354
+ <li class="odd ">
355
+ <div class="item">
356
+ <span class='object_link'><a href="Mint/Money.html#split-instance_method" title="Mint::Money#split (method)">#split</a></span>
357
+ <small>Mint::Money</small>
358
+ </div>
359
+ </li>
360
+
361
+
362
+ <li class="even ">
363
+ <div class="item">
364
+ <span class='object_link'><a href="Mint/Currency.html#subunit-instance_method" title="Mint::Currency#subunit (method)">#subunit</a></span>
365
+ <small>Mint::Currency</small>
366
+ </div>
367
+ </li>
368
+
369
+
370
+ <li class="odd ">
371
+ <div class="item">
372
+ <span class='object_link'><a href="Mint/Money.html#succ-instance_method" title="Mint::Money#succ (method)">#succ</a></span>
373
+ <small>Mint::Money</small>
374
+ </div>
375
+ </li>
376
+
377
+
378
+ <li class="even ">
379
+ <div class="item">
380
+ <span class='object_link'><a href="Mint/Currency.html#symbol-instance_method" title="Mint::Currency#symbol (method)">#symbol</a></span>
381
+ <small>Mint::Currency</small>
382
+ </div>
383
+ </li>
384
+
385
+
386
+ <li class="odd ">
387
+ <div class="item">
388
+ <span class='object_link'><a href="Mint/Money.html#to_d-instance_method" title="Mint::Money#to_d (method)">#to_d</a></span>
389
+ <small>Mint::Money</small>
390
+ </div>
391
+ </li>
392
+
393
+
394
+ <li class="even ">
395
+ <div class="item">
396
+ <span class='object_link'><a href="Mint/Money.html#to_f-instance_method" title="Mint::Money#to_f (method)">#to_f</a></span>
397
+ <small>Mint::Money</small>
398
+ </div>
399
+ </li>
400
+
401
+
402
+ <li class="odd ">
403
+ <div class="item">
404
+ <span class='object_link'><a href="Mint/Money.html#to_hash-instance_method" title="Mint::Money#to_hash (method)">#to_hash</a></span>
405
+ <small>Mint::Money</small>
406
+ </div>
407
+ </li>
408
+
409
+
410
+ <li class="even ">
411
+ <div class="item">
412
+ <span class='object_link'><a href="Mint/Money.html#to_html-instance_method" title="Mint::Money#to_html (method)">#to_html</a></span>
413
+ <small>Mint::Money</small>
414
+ </div>
415
+ </li>
416
+
417
+
418
+ <li class="odd ">
419
+ <div class="item">
420
+ <span class='object_link'><a href="Mint/Money.html#to_i-instance_method" title="Mint::Money#to_i (method)">#to_i</a></span>
421
+ <small>Mint::Money</small>
422
+ </div>
423
+ </li>
424
+
425
+
426
+ <li class="even ">
427
+ <div class="item">
428
+ <span class='object_link'><a href="Mint/Money.html#to_json-instance_method" title="Mint::Money#to_json (method)">#to_json</a></span>
429
+ <small>Mint::Money</small>
430
+ </div>
431
+ </li>
432
+
433
+
434
+ <li class="odd ">
435
+ <div class="item">
436
+ <span class='object_link'><a href="Mint/Money.html#to_r-instance_method" title="Mint::Money#to_r (method)">#to_r</a></span>
437
+ <small>Mint::Money</small>
438
+ </div>
439
+ </li>
440
+
441
+
442
+ <li class="even ">
443
+ <div class="item">
444
+ <span class='object_link'><a href="Mint/Money.html#to_s-instance_method" title="Mint::Money#to_s (method)">#to_s</a></span>
445
+ <small>Mint::Money</small>
446
+ </div>
447
+ </li>
448
+
449
+
450
+ <li class="odd ">
451
+ <div class="item">
452
+ <span class='object_link'><a href="Mint.html#zero-class_method" title="Mint.zero (method)">zero</a></span>
453
+ <small>Mint</small>
454
+ </div>
455
+ </li>
456
+
457
+
458
+ <li class="even ">
459
+ <div class="item">
460
+ <span class='object_link'><a href="Mint/Money.html#zero%3F-instance_method" title="Mint::Money#zero? (method)">#zero?</a></span>
461
+ <small>Mint::Money</small>
462
+ </div>
463
+ </li>
464
+
465
+
466
+
467
+ </ul>
468
+ </div>
469
+ </body>
470
+ </html>
@@ -0,0 +1,112 @@
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
+ Top Level Namespace
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 = "";
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</a> &raquo;
42
+
43
+
44
+ <span class="title">Top Level Namespace</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>Top Level Namespace
65
+
66
+
67
+
68
+ </h1>
69
+ <div class="box_info">
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ </div>
82
+
83
+ <h2>Defined Under Namespace</h2>
84
+ <p class="children">
85
+
86
+
87
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mint.html" title="Mint (module)">Mint</a></span>, <span class='object_link'><a href="Minting.html" title="Minting (module)">Minting</a></span>
88
+
89
+
90
+
91
+
92
+ </p>
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ </div>
103
+
104
+ <div id="footer">
105
+ Generated on Tue Jun 2 14:44:35 2026 by
106
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
+ 0.9.44 (ruby-4.0.1).
108
+ </div>
109
+
110
+ </div>
111
+ </body>
112
+ </html>
@@ -19,7 +19,7 @@ module Mint
19
19
  private
20
20
 
21
21
  def initialize(code:, symbol:, subunit: 0, priority: 0, country: nil, name: nil)
22
- @code = code.to_s
22
+ @code = code
23
23
  @subunit = subunit.to_i
24
24
  @symbol = symbol
25
25
  @priority = priority.to_i
@@ -20,35 +20,27 @@ module Mint
20
20
  # Finds a registered currency by its code, symbol,
21
21
  # or retrieves it directly if already a Currency object.
22
22
  #
23
- # @param currency [String, Symbol, Currency] the currency identifier or object
23
+ # @param currency [String, Currency] the currency identifier or object
24
24
  # @return [Currency, nil] the registered Currency instance or nil if not found
25
25
  def self.currency(currency)
26
- case currency
27
- when Currency
28
- currency
29
- when Symbol
30
- currencies[currency.to_s]
31
- else
32
- currencies[currency]
33
- end
26
+ currency.is_a?(Currency) ? currency : currencies[currency]
34
27
  end
35
28
 
36
29
  # Registers a new currency if not already registered.
37
30
  #
38
- # @param code [String, Symbol] the unique currency code (e.g. 'USD', :EUR)
31
+ # @param code [String] the unique currency code (e.g. 'USD', 'EUR')
39
32
  # @param subunit [Integer] the decimal subunit precision (defaults to 2)
40
33
  # @param symbol [String] the display symbol (defaults to '')
41
34
  # @param priority [Integer] parser precedence priority (defaults to 0)
42
35
  # @return [Currency] the registered or existing Currency instance
43
36
  # @raise [ArgumentError] if the code layout is invalid or register throws an error
44
37
  def self.register_currency(code:, subunit: 2, symbol: '', priority: 0)
45
- code = code.to_s
46
38
  currencies[code] || register_currency!(code:, subunit:, symbol:, priority:)
47
39
  end
48
40
 
49
41
  # Strictly registers a new currency, raising a KeyError if already registered.
50
42
  #
51
- # @param code [String, Symbol] the unique currency code
43
+ # @param code [String] the unique currency code
52
44
  # @param subunit [Integer] the decimal subunit precision
53
45
  # @param symbol [String] the display symbol
54
46
  # @param priority [Integer] parser precedence priority
@@ -56,16 +48,15 @@ module Mint
56
48
  # @raise [ArgumentError] if the code contains invalid characters
57
49
  # @raise [KeyError] if the currency code is already registered
58
50
  def self.register_currency!(code:, subunit:, symbol: '', priority: 0)
59
- code = code.to_s
51
+ raise ArgumentError, 'Currency code must be String' unless code.is_a? String
60
52
  unless code.match?(/^[A-Z_]+$/)
61
53
  raise ArgumentError,
62
- "Currency code must be String or Symbol ('USD', :EUR, 'FUEL', 'MY_COIN')"
63
- end
64
- if currencies[code]
65
- raise KeyError,
66
- "Currency: #{code} already registered"
54
+ "Currency code must only letters or '_' ('USD',, 'MY_COIN')"
67
55
  end
68
56
 
57
+ currency = currencies[code]
58
+ raise KeyError, "Currency: #{code} already registered" if currency
59
+
69
60
  currency = currencies[code] = Currency.new(code:, subunit:, symbol:, priority:)
70
61
  @currency_symbols = nil
71
62
  currency