GTK/Utils.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 5 SCAR 29.7
CC
5
Cov
0%
bytes2size
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 19.5
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2016 -- leonerd@leonerd.org.uk
5  
6 package App::Devel::MAT::Explorer::GTK::Utils;
7  
8 use strict;
9 use warnings;
10  
11 use Exporter 'import';
12  
13 our @EXPORT = qw(
14 bytes2size
15 );
16  
17 sub bytes2size
18 {
19 my ( $bytes ) = @_;
20  
21 if( $bytes < 1024 ) {
22 return $bytes
23 }
24 if( $bytes < 1024**2 ) {
25 return sprintf "%.1f Ki", $bytes / 1024;
26 }
27 if( $bytes < 1024**3 ) {
28 return sprintf "%.1f Mi", $bytes / 1024**2;
29 }
30 if( $bytes < 1024**4 ) {
31 return sprintf "%.1f Gi", $bytes / 1024**3;
32 }
33 return sprintf "%.1f Ti", $bytes / 1024**4;
34 }
35