minting 1.7.0 → 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 +80 -112
- data/Rakefile +13 -1
- data/bin/bench_check +46 -0
- data/doc/Mint/Currency.html +446 -46
- data/doc/Mint/CurrencyRegistry.html +7 -7
- data/doc/Mint/Money.html +203 -177
- data/doc/Mint/RangeStepPatch.html +277 -0
- data/doc/Mint/Registry.html +842 -0
- data/doc/Mint/UnknownCurrency.html +2 -2
- data/doc/Mint.html +385 -66
- data/doc/Minting.html +3 -3
- data/doc/_index.html +24 -9
- data/doc/agents/api_review-2026-06-15.md +342 -0
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +97 -89
- data/doc/index.html +97 -89
- data/doc/method_list.html +97 -25
- data/doc/top-level-namespace.html +13 -5
- data/lib/minting/currency/currency.rb +75 -0
- data/lib/minting/mint/aliases.rb +3 -0
- data/lib/minting/mint/dsl/{refinements.rb → numeric.rb} +6 -5
- data/lib/minting/mint/dsl/range.rb +31 -18
- data/lib/minting/mint/dsl/string.rb +12 -0
- data/lib/minting/mint/dsl/top_level.rb +3 -0
- data/lib/minting/mint/locale_backend.rb +29 -0
- data/lib/minting/mint/mint.rb +28 -12
- data/lib/minting/mint/parser/parser.rb +62 -0
- data/lib/minting/mint/parser/separators.rb +39 -0
- 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 -16
- data/lib/minting/money/allocation/allocation.rb +25 -0
- data/lib/minting/money/{allocation.rb → allocation/split.rb} +1 -19
- data/lib/minting/money/arithmetics/methods.rb +27 -0
- data/lib/minting/money/{arithmetics.rb → arithmetics/operators.rb} +0 -21
- data/lib/minting/money/clamp.rb +66 -0
- data/lib/minting/money/coercion.rb +10 -0
- data/lib/minting/money/comparable.rb +6 -0
- data/lib/minting/money/constructors.rb +14 -9
- data/lib/minting/money/format/formatting.rb +60 -0
- data/lib/minting/money/{formatting.rb → format/to_s.rb} +13 -36
- data/lib/minting/money/money.rb +12 -58
- data/lib/minting/version.rb +1 -1
- metadata +29 -19
- data/lib/minting/mint/currency/currency.rb +0 -36
- data/lib/minting/mint/currency/currency_registry.rb +0 -67
- data/lib/minting/mint/currency/world_currencies.rb +0 -16
- data/lib/minting/mint/parser.rb +0 -85
- /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
data/doc/Mint/Currency.html
CHANGED
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
|
|
99
99
|
<dl>
|
|
100
100
|
<dt>Defined in:</dt>
|
|
101
|
-
<dd>lib/minting/
|
|
101
|
+
<dd>lib/minting/currency/currency.rb
|
|
102
102
|
</dd>
|
|
103
103
|
</dl>
|
|
104
104
|
|
|
@@ -324,6 +324,60 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
|
|
327
|
+
<h2>
|
|
328
|
+
Class Method Summary
|
|
329
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
330
|
+
</h2>
|
|
331
|
+
|
|
332
|
+
<ul class="summary">
|
|
333
|
+
|
|
334
|
+
<li class="public ">
|
|
335
|
+
<span class="summary_signature">
|
|
336
|
+
|
|
337
|
+
<a href="#resolve-class_method" title="resolve (class method)">.<strong>resolve</strong>(object) ⇒ Currency<sup>?</sup> </a>
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
</span>
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
<span class="summary_desc"><div class='inline'><p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span>, returning <code>nil</code> when it can't.</p></div></span>
|
|
352
|
+
|
|
353
|
+
</li>
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
<li class="public ">
|
|
357
|
+
<span class="summary_signature">
|
|
358
|
+
|
|
359
|
+
<a href="#resolve!-class_method" title="resolve! (class method)">.<strong>resolve!</strong>(object) ⇒ Currency </a>
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
</span>
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
<span class="summary_desc"><div class='inline'><p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span>, raising on failure.</p></div></span>
|
|
374
|
+
|
|
375
|
+
</li>
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
</ul>
|
|
379
|
+
|
|
380
|
+
|
|
327
381
|
<h2>
|
|
328
382
|
Instance Method Summary
|
|
329
383
|
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
@@ -358,7 +412,7 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
358
412
|
<li class="public ">
|
|
359
413
|
<span class="summary_signature">
|
|
360
414
|
|
|
361
|
-
<a href="#inspect-instance_method" title="#inspect (instance method)">#<strong>inspect</strong> ⇒
|
|
415
|
+
<a href="#inspect-instance_method" title="#inspect (instance method)">#<strong>inspect</strong> ⇒ String </a>
|
|
362
416
|
|
|
363
417
|
|
|
364
418
|
|
|
@@ -372,7 +426,7 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
372
426
|
|
|
373
427
|
|
|
374
428
|
|
|
375
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
|
429
|
+
<span class="summary_desc"><div class='inline'><p>Debug representation.</p></div></span>
|
|
376
430
|
|
|
377
431
|
</li>
|
|
378
432
|
|
|
@@ -380,7 +434,7 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
380
434
|
<li class="public ">
|
|
381
435
|
<span class="summary_signature">
|
|
382
436
|
|
|
383
|
-
<a href="#minimum_amount-instance_method" title="#minimum_amount (instance method)">#<strong>minimum_amount</strong> ⇒
|
|
437
|
+
<a href="#minimum_amount-instance_method" title="#minimum_amount (instance method)">#<strong>minimum_amount</strong> ⇒ Rational </a>
|
|
384
438
|
|
|
385
439
|
|
|
386
440
|
|
|
@@ -394,7 +448,7 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
394
448
|
|
|
395
449
|
|
|
396
450
|
|
|
397
|
-
<span class="summary_desc"><div class='inline'></div></span>
|
|
451
|
+
<span class="summary_desc"><div class='inline'><p>Smallest representable amount (1/fractional_multiplier).</p></div></span>
|
|
398
452
|
|
|
399
453
|
</li>
|
|
400
454
|
|
|
@@ -445,7 +499,103 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
445
499
|
</div>
|
|
446
500
|
</div>
|
|
447
501
|
<div class="tags">
|
|
502
|
+
<p class="tag_title">Parameters:</p>
|
|
503
|
+
<ul class="param">
|
|
504
|
+
|
|
505
|
+
<li>
|
|
506
|
+
|
|
507
|
+
<span class='name'>code</span>
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
—
|
|
515
|
+
<div class='inline'><p>ISO 4217 currency code</p></div>
|
|
516
|
+
|
|
517
|
+
</li>
|
|
518
|
+
|
|
519
|
+
<li>
|
|
520
|
+
|
|
521
|
+
<span class='name'>symbol</span>
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
—
|
|
529
|
+
<div class='inline'><p>Display symbol</p></div>
|
|
530
|
+
|
|
531
|
+
</li>
|
|
532
|
+
|
|
533
|
+
<li>
|
|
534
|
+
|
|
535
|
+
<span class='name'>subunit</span>
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
—
|
|
545
|
+
<div class='inline'><p>Number of decimal places (default 0)</p></div>
|
|
546
|
+
|
|
547
|
+
</li>
|
|
448
548
|
|
|
549
|
+
<li>
|
|
550
|
+
|
|
551
|
+
<span class='name'>priority</span>
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
<span class='type'>(<tt>Integer</tt>)</span>
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
<em class="default">(defaults to: <tt>0</tt>)</em>
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
—
|
|
561
|
+
<div class='inline'><p>Parser precedence for symbol detection (default 0)</p></div>
|
|
562
|
+
|
|
563
|
+
</li>
|
|
564
|
+
|
|
565
|
+
<li>
|
|
566
|
+
|
|
567
|
+
<span class='name'>country</span>
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
<span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
—
|
|
577
|
+
<div class='inline'><p>Associated country code (default nil)</p></div>
|
|
578
|
+
|
|
579
|
+
</li>
|
|
580
|
+
|
|
581
|
+
<li>
|
|
582
|
+
|
|
583
|
+
<span class='name'>name</span>
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
<span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
—
|
|
593
|
+
<div class='inline'><p>Currency name (default nil)</p></div>
|
|
594
|
+
|
|
595
|
+
</li>
|
|
596
|
+
|
|
597
|
+
</ul>
|
|
598
|
+
|
|
449
599
|
|
|
450
600
|
</div><table class="source_code">
|
|
451
601
|
<tr>
|
|
@@ -453,16 +603,16 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
453
603
|
<pre class="lines">
|
|
454
604
|
|
|
455
605
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
606
|
+
26
|
|
607
|
+
27
|
|
608
|
+
28
|
|
609
|
+
29
|
|
610
|
+
30
|
|
611
|
+
31
|
|
612
|
+
32</pre>
|
|
463
613
|
</td>
|
|
464
614
|
<td>
|
|
465
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
615
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 26</span>
|
|
466
616
|
|
|
467
617
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>code:</span><span class='comma'>,</span> <span class='label'>symbol:</span><span class='comma'>,</span> <span class='label'>subunit:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>country:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>name:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
468
618
|
<span class='id identifier rubyid_subunit'>subunit</span> <span class='op'>=</span> <span class='id identifier rubyid_subunit'>subunit</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span>
|
|
@@ -523,12 +673,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
523
673
|
<pre class="lines">
|
|
524
674
|
|
|
525
675
|
|
|
526
|
-
17
|
|
527
676
|
18
|
|
528
|
-
19
|
|
677
|
+
19
|
|
678
|
+
20</pre>
|
|
529
679
|
</td>
|
|
530
680
|
<td>
|
|
531
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
681
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
532
682
|
|
|
533
683
|
<span class='kw'>def</span> <span class='id identifier rubyid_code'>code</span>
|
|
534
684
|
<span class='ivar'>@code</span>
|
|
@@ -580,12 +730,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
580
730
|
<pre class="lines">
|
|
581
731
|
|
|
582
732
|
|
|
583
|
-
17
|
|
584
733
|
18
|
|
585
|
-
19
|
|
734
|
+
19
|
|
735
|
+
20</pre>
|
|
586
736
|
</td>
|
|
587
737
|
<td>
|
|
588
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
738
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
589
739
|
|
|
590
740
|
<span class='kw'>def</span> <span class='id identifier rubyid_country'>country</span>
|
|
591
741
|
<span class='ivar'>@country</span>
|
|
@@ -637,12 +787,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
637
787
|
<pre class="lines">
|
|
638
788
|
|
|
639
789
|
|
|
640
|
-
17
|
|
641
790
|
18
|
|
642
|
-
19
|
|
791
|
+
19
|
|
792
|
+
20</pre>
|
|
643
793
|
</td>
|
|
644
794
|
<td>
|
|
645
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
795
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
646
796
|
|
|
647
797
|
<span class='kw'>def</span> <span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span>
|
|
648
798
|
<span class='ivar'>@fractional_multiplier</span>
|
|
@@ -694,12 +844,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
694
844
|
<pre class="lines">
|
|
695
845
|
|
|
696
846
|
|
|
697
|
-
17
|
|
698
847
|
18
|
|
699
|
-
19
|
|
848
|
+
19
|
|
849
|
+
20</pre>
|
|
700
850
|
</td>
|
|
701
851
|
<td>
|
|
702
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
852
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
703
853
|
|
|
704
854
|
<span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
|
|
705
855
|
<span class='ivar'>@name</span>
|
|
@@ -751,12 +901,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
751
901
|
<pre class="lines">
|
|
752
902
|
|
|
753
903
|
|
|
754
|
-
17
|
|
755
904
|
18
|
|
756
|
-
19
|
|
905
|
+
19
|
|
906
|
+
20</pre>
|
|
757
907
|
</td>
|
|
758
908
|
<td>
|
|
759
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
909
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
760
910
|
|
|
761
911
|
<span class='kw'>def</span> <span class='id identifier rubyid_priority'>priority</span>
|
|
762
912
|
<span class='ivar'>@priority</span>
|
|
@@ -808,12 +958,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
808
958
|
<pre class="lines">
|
|
809
959
|
|
|
810
960
|
|
|
811
|
-
17
|
|
812
961
|
18
|
|
813
|
-
19
|
|
962
|
+
19
|
|
963
|
+
20</pre>
|
|
814
964
|
</td>
|
|
815
965
|
<td>
|
|
816
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
966
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
817
967
|
|
|
818
968
|
<span class='kw'>def</span> <span class='id identifier rubyid_subunit'>subunit</span>
|
|
819
969
|
<span class='ivar'>@subunit</span>
|
|
@@ -865,12 +1015,12 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
865
1015
|
<pre class="lines">
|
|
866
1016
|
|
|
867
1017
|
|
|
868
|
-
17
|
|
869
1018
|
18
|
|
870
|
-
19
|
|
1019
|
+
19
|
|
1020
|
+
20</pre>
|
|
871
1021
|
</td>
|
|
872
1022
|
<td>
|
|
873
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
1023
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 18</span>
|
|
874
1024
|
|
|
875
1025
|
<span class='kw'>def</span> <span class='id identifier rubyid_symbol'>symbol</span>
|
|
876
1026
|
<span class='ivar'>@symbol</span>
|
|
@@ -883,6 +1033,206 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
883
1033
|
</div>
|
|
884
1034
|
|
|
885
1035
|
|
|
1036
|
+
<div id="class_method_details" class="method_details_list">
|
|
1037
|
+
<h2>Class Method Details</h2>
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
<div class="method_details first">
|
|
1041
|
+
<h3 class="signature first" id="resolve-class_method">
|
|
1042
|
+
|
|
1043
|
+
.<strong>resolve</strong>(object) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt><sup>?</sup>
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
</h3><div class="docstring">
|
|
1050
|
+
<div class="discussion">
|
|
1051
|
+
<p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Mint::Currency</a></span>, returning <code>nil</code> when it can't.</p>
|
|
1052
|
+
<p>Accepts <code>nil</code>, <code>String</code>, <span class='object_link'><a href="" title="Mint::Currency (class)">Mint::Currency</a></span>, or <span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span>.
|
|
1053
|
+
Passing a <span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span> extracts its currency</p>
|
|
1054
|
+
|
|
1055
|
+
</div>
|
|
1056
|
+
</div>
|
|
1057
|
+
<div class="tags">
|
|
1058
|
+
<p class="tag_title">Parameters:</p>
|
|
1059
|
+
<ul class="param">
|
|
1060
|
+
|
|
1061
|
+
<li>
|
|
1062
|
+
|
|
1063
|
+
<span class='name'>object</span>
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
<span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>, <tt>nil</tt>)</span>
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
—
|
|
1071
|
+
<div class='inline'><p>a currency code, object, or <code>nil</code></p></div>
|
|
1072
|
+
|
|
1073
|
+
</li>
|
|
1074
|
+
|
|
1075
|
+
</ul>
|
|
1076
|
+
|
|
1077
|
+
<p class="tag_title">Returns:</p>
|
|
1078
|
+
<ul class="return">
|
|
1079
|
+
|
|
1080
|
+
<li>
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt>nil</tt>)</span>
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
—
|
|
1088
|
+
<div class='inline'><p>the resolved Currency, or <code>nil</code> if <code>object</code> is <code>nil</code>
|
|
1089
|
+
or the code is not registered</p></div>
|
|
1090
|
+
|
|
1091
|
+
</li>
|
|
1092
|
+
|
|
1093
|
+
</ul>
|
|
1094
|
+
<p class="tag_title">Raises:</p>
|
|
1095
|
+
<ul class="raise">
|
|
1096
|
+
|
|
1097
|
+
<li>
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
—
|
|
1105
|
+
<div class='inline'><p>if <code>object</code> is an unsupported type (e.g. <code>Integer</code>)</p></div>
|
|
1106
|
+
|
|
1107
|
+
</li>
|
|
1108
|
+
|
|
1109
|
+
</ul>
|
|
1110
|
+
|
|
1111
|
+
</div><table class="source_code">
|
|
1112
|
+
<tr>
|
|
1113
|
+
<td>
|
|
1114
|
+
<pre class="lines">
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
55
|
|
1118
|
+
56
|
|
1119
|
+
57
|
|
1120
|
+
58
|
|
1121
|
+
59
|
|
1122
|
+
60
|
|
1123
|
+
61
|
|
1124
|
+
62
|
|
1125
|
+
63</pre>
|
|
1126
|
+
</td>
|
|
1127
|
+
<td>
|
|
1128
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 55</span>
|
|
1129
|
+
|
|
1130
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
|
|
1131
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_object'>object</span>
|
|
1132
|
+
<span class='kw'>when</span> <span class='const'>NilClass</span> <span class='kw'>then</span> <span class='kw'>nil</span>
|
|
1133
|
+
<span class='kw'>when</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span> <span class='kw'>then</span> <span class='id identifier rubyid_object'>object</span>
|
|
1134
|
+
<span class='kw'>when</span> <span class='const'><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></span> <span class='kw'>then</span> <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_currency'>currency</span>
|
|
1135
|
+
<span class='kw'>when</span> <span class='const'>String</span> <span class='kw'>then</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_currency_for_code'><span class='object_link'><a href="../Mint.html#currency_for_code-class_method" title="Mint.currency_for_code (method)">currency_for_code</a></span></span> <span class='id identifier rubyid_object'>object</span>
|
|
1136
|
+
<span class='kw'>else</span> <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 must be [Currency], [Money], [String] or nil (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='embexpr_end'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span>
|
|
1137
|
+
<span class='kw'>end</span>
|
|
1138
|
+
<span class='kw'>end</span></pre>
|
|
1139
|
+
</td>
|
|
1140
|
+
</tr>
|
|
1141
|
+
</table>
|
|
1142
|
+
</div>
|
|
1143
|
+
|
|
1144
|
+
<div class="method_details ">
|
|
1145
|
+
<h3 class="signature " id="resolve!-class_method">
|
|
1146
|
+
|
|
1147
|
+
.<strong>resolve!</strong>(object) ⇒ <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
</h3><div class="docstring">
|
|
1154
|
+
<div class="discussion">
|
|
1155
|
+
<p>Resolves an object into a <span class='object_link'><a href="" title="Mint::Currency (class)">Mint::Currency</a></span>, raising on failure.</p>
|
|
1156
|
+
<p>Like <span class='object_link'><a href="#resolve-class_method" title="Mint::Currency.resolve (method)">resolve</a></span> but raises when the result would be <code>nil</code>.</p>
|
|
1157
|
+
|
|
1158
|
+
</div>
|
|
1159
|
+
</div>
|
|
1160
|
+
<div class="tags">
|
|
1161
|
+
<p class="tag_title">Parameters:</p>
|
|
1162
|
+
<ul class="param">
|
|
1163
|
+
|
|
1164
|
+
<li>
|
|
1165
|
+
|
|
1166
|
+
<span class='name'>object</span>
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
<span class='type'>(<tt>String</tt>, <tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>, <tt><span class='object_link'><a href="Money.html" title="Mint::Money (class)">Money</a></span></tt>, <tt>nil</tt>)</span>
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
—
|
|
1174
|
+
<div class='inline'><p>a currency code, object, or <code>nil</code></p></div>
|
|
1175
|
+
|
|
1176
|
+
</li>
|
|
1177
|
+
|
|
1178
|
+
</ul>
|
|
1179
|
+
|
|
1180
|
+
<p class="tag_title">Returns:</p>
|
|
1181
|
+
<ul class="return">
|
|
1182
|
+
|
|
1183
|
+
<li>
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></tt>)</span>
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
—
|
|
1191
|
+
<div class='inline'><p>the resolved Currency</p></div>
|
|
1192
|
+
|
|
1193
|
+
</li>
|
|
1194
|
+
|
|
1195
|
+
</ul>
|
|
1196
|
+
<p class="tag_title">Raises:</p>
|
|
1197
|
+
<ul class="raise">
|
|
1198
|
+
|
|
1199
|
+
<li>
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
—
|
|
1207
|
+
<div class='inline'><p>if <code>object</code> cannot be resolved into a registered currency</p></div>
|
|
1208
|
+
|
|
1209
|
+
</li>
|
|
1210
|
+
|
|
1211
|
+
</ul>
|
|
1212
|
+
|
|
1213
|
+
</div><table class="source_code">
|
|
1214
|
+
<tr>
|
|
1215
|
+
<td>
|
|
1216
|
+
<pre class="lines">
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
72
|
|
1220
|
+
73
|
|
1221
|
+
74</pre>
|
|
1222
|
+
</td>
|
|
1223
|
+
<td>
|
|
1224
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 72</span>
|
|
1225
|
+
|
|
1226
|
+
<span class='kw'>def</span> <span class='const'><span class='object_link'><a href="" title="Mint::Currency (class)">Currency</a></span></span><span class='period'>.</span><span class='id identifier rubyid_resolve!'>resolve!</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
|
|
1227
|
+
<span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span> <span class='kw'>or</span> <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'>Could not resolve (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='embexpr_end'>}</span><span class='tstring_content'>) into a currency</span><span class='tstring_end'>"</span></span>
|
|
1228
|
+
<span class='kw'>end</span></pre>
|
|
1229
|
+
</td>
|
|
1230
|
+
</tr>
|
|
1231
|
+
</table>
|
|
1232
|
+
</div>
|
|
1233
|
+
|
|
1234
|
+
</div>
|
|
1235
|
+
|
|
886
1236
|
<div id="instance_method_details" class="method_details_list">
|
|
887
1237
|
<h2>Instance Method Details</h2>
|
|
888
1238
|
|
|
@@ -890,22 +1240,47 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
890
1240
|
<div class="method_details first">
|
|
891
1241
|
<h3 class="signature first" id="inspect-instance_method">
|
|
892
1242
|
|
|
893
|
-
#<strong>inspect</strong> ⇒ <tt>
|
|
1243
|
+
#<strong>inspect</strong> ⇒ <tt>String</tt>
|
|
1244
|
+
|
|
1245
|
+
|
|
894
1246
|
|
|
895
1247
|
|
|
896
1248
|
|
|
1249
|
+
</h3><div class="docstring">
|
|
1250
|
+
<div class="discussion">
|
|
1251
|
+
<p>Returns debug representation.</p>
|
|
897
1252
|
|
|
1253
|
+
</div>
|
|
1254
|
+
</div>
|
|
1255
|
+
<div class="tags">
|
|
898
1256
|
|
|
899
|
-
|
|
1257
|
+
<p class="tag_title">Returns:</p>
|
|
1258
|
+
<ul class="return">
|
|
1259
|
+
|
|
1260
|
+
<li>
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
—
|
|
1268
|
+
<div class='inline'><p>debug representation</p></div>
|
|
1269
|
+
|
|
1270
|
+
</li>
|
|
1271
|
+
|
|
1272
|
+
</ul>
|
|
1273
|
+
|
|
1274
|
+
</div><table class="source_code">
|
|
900
1275
|
<tr>
|
|
901
1276
|
<td>
|
|
902
1277
|
<pre class="lines">
|
|
903
1278
|
|
|
904
1279
|
|
|
905
|
-
|
|
1280
|
+
35</pre>
|
|
906
1281
|
</td>
|
|
907
1282
|
<td>
|
|
908
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
1283
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 35</span>
|
|
909
1284
|
|
|
910
1285
|
<span class='kw'>def</span> <span class='id identifier rubyid_inspect'>inspect</span> <span class='op'>=</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'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_symbol'>symbol</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_subunit'>subunit</span><span class='embexpr_end'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>)></span><span class='tstring_end'>"</span></span></pre>
|
|
911
1286
|
</td>
|
|
@@ -916,22 +1291,47 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
916
1291
|
<div class="method_details ">
|
|
917
1292
|
<h3 class="signature " id="minimum_amount-instance_method">
|
|
918
1293
|
|
|
919
|
-
#<strong>minimum_amount</strong> ⇒ <tt>
|
|
1294
|
+
#<strong>minimum_amount</strong> ⇒ <tt>Rational</tt>
|
|
920
1295
|
|
|
921
1296
|
|
|
922
1297
|
|
|
923
1298
|
|
|
924
1299
|
|
|
925
|
-
</h3><
|
|
1300
|
+
</h3><div class="docstring">
|
|
1301
|
+
<div class="discussion">
|
|
1302
|
+
<p>Returns smallest representable amount (1/fractional_multiplier).</p>
|
|
1303
|
+
|
|
1304
|
+
</div>
|
|
1305
|
+
</div>
|
|
1306
|
+
<div class="tags">
|
|
1307
|
+
|
|
1308
|
+
<p class="tag_title">Returns:</p>
|
|
1309
|
+
<ul class="return">
|
|
1310
|
+
|
|
1311
|
+
<li>
|
|
1312
|
+
|
|
1313
|
+
|
|
1314
|
+
<span class='type'>(<tt>Rational</tt>)</span>
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
—
|
|
1319
|
+
<div class='inline'><p>smallest representable amount (1/fractional_multiplier)</p></div>
|
|
1320
|
+
|
|
1321
|
+
</li>
|
|
1322
|
+
|
|
1323
|
+
</ul>
|
|
1324
|
+
|
|
1325
|
+
</div><table class="source_code">
|
|
926
1326
|
<tr>
|
|
927
1327
|
<td>
|
|
928
1328
|
<pre class="lines">
|
|
929
1329
|
|
|
930
1330
|
|
|
931
|
-
|
|
1331
|
+
38</pre>
|
|
932
1332
|
</td>
|
|
933
1333
|
<td>
|
|
934
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
1334
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 38</span>
|
|
935
1335
|
|
|
936
1336
|
<span class='kw'>def</span> <span class='id identifier rubyid_minimum_amount'>minimum_amount</span> <span class='op'>=</span> <span class='const'>Rational</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='id identifier rubyid_fractional_multiplier'>fractional_multiplier</span><span class='rparen'>)</span></pre>
|
|
937
1337
|
</td>
|
|
@@ -967,10 +1367,10 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
967
1367
|
<pre class="lines">
|
|
968
1368
|
|
|
969
1369
|
|
|
970
|
-
|
|
1370
|
+
43</pre>
|
|
971
1371
|
</td>
|
|
972
1372
|
<td>
|
|
973
|
-
<pre class="code"><span class="info file"># File 'lib/minting/
|
|
1373
|
+
<pre class="code"><span class="info file"># File 'lib/minting/currency/currency.rb', line 43</span>
|
|
974
1374
|
|
|
975
1375
|
<span class='kw'>def</span> <span class='id identifier rubyid_normalize_amount'>normalize_amount</span><span class='lparen'>(</span><span class='id identifier rubyid_amount'>amount</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_amount'>amount</span><span class='period'>.</span><span class='id identifier rubyid_to_r'>to_r</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='id identifier rubyid_subunit'>subunit</span><span class='rparen'>)</span></pre>
|
|
976
1376
|
</td>
|
|
@@ -983,9 +1383,9 @@ including its subunit precision, display symbol, and formatting rules.</p>
|
|
|
983
1383
|
</div>
|
|
984
1384
|
|
|
985
1385
|
<div id="footer">
|
|
986
|
-
Generated on
|
|
1386
|
+
Generated on Mon Jun 15 19:57:57 2026 by
|
|
987
1387
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
988
|
-
0.9.44 (ruby-4.0.
|
|
1388
|
+
0.9.44 (ruby-4.0.5).
|
|
989
1389
|
</div>
|
|
990
1390
|
|
|
991
1391
|
</div>
|