File Coverage

blib/lib/Lingua/ID/Number/Format/MixWithWords.pm
Criterion Covered Total %
statement 39 39 100.0
branch n/a
condition 3 7 42.8
subroutine 12 12 100.0
pod 1 2 50.0
total 55 60 91.6


line stmt bran cond sub pod time code
1             package Lingua::ID::Number::Format::MixWithWords;
2              
3 2     2   872 use 5.010001;
  2         7  
  2         67  
4 2     2   10 use strict;
  2         3  
  2         48  
5 2     2   10 use warnings;
  2         2  
  2         75  
6              
7 2     2   1976 use Lingua::Base::Number::Format::MixWithWords;
  2         68371  
  2         75  
8 2     2   1906 use parent qw(Lingua::Base::Number::Format::MixWithWords);
  2         894  
  2         13  
9             require Lingua::EN::Number::Format::MixWithWords;
10              
11 2     2   7478 use Data::Clone;
  2         1813  
  2         147  
12 2     2   1775 use Exporter::Lite;
  2         1436  
  2         12  
13 2     2   95 use Math::Round qw(nearest);
  2         4  
  2         96  
14 2     2   11 use Number::Format;
  2         4  
  2         80  
15 2     2   19 use POSIX qw(floor log10);
  2         4  
  2         15  
16              
17             our @EXPORT_OK = qw(format_number_mix);
18              
19             our $VERSION = '0.05'; # VERSION
20              
21             our %SPEC;
22             $SPEC{format_number_mix} = clone(
23             $Lingua::EN::Number::Format::MixWithWords::SPEC{format_number_mix});
24             delete $SPEC{format_number_mix}{args}{scale};
25              
26             sub format_number_mix {
27 16     16 1 65375 my %args = @_;
28              
29 16         118 my $f = __PACKAGE__->new(
30             num_decimal => $args{num_decimal},
31             min_format => $args{min_format},
32             min_fraction => $args{min_fraction},
33             );
34 16         304 $f->_format($args{num});
35             }
36              
37             my $id_names = {
38             #2 => 'ratus',
39             3 => 'ribu',
40             6 => 'juta',
41             9 => 'miliar',
42             12 => 'triliun',
43             15 => 'kuadriliun',
44             18 => 'kuintiliun',
45             21 => 'sekstiliun',
46             24 => 'septiliun',
47             27 => 'oktiliun',
48             30 => 'noniliun',
49             33 => 'desiliun',
50             36 => 'undesiliun',
51             39 => 'duodesiliun',
52             42 => 'tredesiliun',
53             45 => 'kuatuordesiliun',
54             48 => 'kuindesiliun',
55             51 => 'seksdesiliun',
56             54 => 'septendesiliun',
57             57 => 'oktodesiliun',
58             60 => 'novemdesiliun',
59             63 => 'vigintiliun',
60             100 => 'googol',
61             303 => 'sentiliun',
62             };
63              
64             sub new {
65 16     16 0 90 my ($class, %args) = @_;
66 16   50     173 $args{decimal_point} //= ",";
67 16   50     166 $args{thousands_sep} //= ".";
68 16   33     99 $args{names} //= $id_names;
69              
70             # XXX should use "SUPER"
71 16         110 my $self = Lingua::Base::Number::Format::MixWithWords->new(%args);
72 16         10964 bless $self, $class;
73             }
74              
75             1;
76             # ABSTRACT: Format number to a mixture of numbers and words (e.g. "12,3 juta")
77              
78             __END__