Subject: | format_bytes options, documentation |
format_bytes calls format_number internally, but does not export all it's options.
Thus, format_bytes obeys the object's options that 'belong' to format_number.
a) This is not clear in the documentation.
b) I wanted format_bytes to produce trailing zeros (for a table). That is,
the equivalent of format_number's $trailing_zeroes. I eventually found that
creatng an extra object with decimal_fill => 1 was equivalent.
It would be more convenient to have a 'trailing' ( or 'decimal_fill' ) option
for format_bytes. This would provide a value for the call independent of
the object/global variables' state.
c) For the convenience of those who make multiple calls with the same
(precision, unit,base,mode (and trailing) parameters, you might consider
accepting a hashref for options. This would allow for more concise calls
(and centralize options in the caller). E.g.
my $opts = { mode => 'traditional, precision => 2, trailing => 1 };
$number->format_bytes( $n ); $number->format_bytes( $m ); ...