[ANN] Bytes, a convenience to print the size of things

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] Bytes, a convenience to print the size of things

sebastianconcept@gmail.co
Hi there,

I've published a package to help printing measures of bytes in a human readable fashion.

Here is is:
http://www.squeaksource.com/Bytes

Examples:

        2 gigabytes asMegabyteString "will give you '2048 MB' if you print it"

for those who have stored half of the galaxy its range goes from kilo to yatto

enjoy

sebastian
PS: it uses Aconcagua as foundation so be sure to install it first

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Bytes, a convenience to print the size of things

Stéphane Ducasse
neat :)
May be you should create a metacello configuration for it.

On Jun 12, 2010, at 5:03 PM, [hidden email] wrote:

> Hi there,
>
> I've published a package to help printing measures of bytes in a human readable fashion.
>
> Here is is:
> http://www.squeaksource.com/Bytes
>
> Examples:
>
> 2 gigabytes asMegabyteString "will give you '2048 MB' if you print it"
>
> for those who have stored half of the galaxy its range goes from kilo to yatto
>
> enjoy
>
> sebastian
> PS: it uses Aconcagua as foundation so be sure to install it first
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Bytes, a convenience to print the size of things

Chris Muller-3
In reply to this post by sebastianconcept@gmail.co
Just FYI, there's also a single-method version of this behavior which
has been available in the "Ma base additions" package for some years
now..

maAsBytesDescription
        | suffixes |
        suffixes := { 'k'"ilobytes". 'M'"egabytes". 'G'"igabytes".
'T'"erabytes". 'P'"etabytes". 'E'"xabytes". 'Z'"ettabytes".
'Y'"ottabytes"}.
        suffixes size to: 1 by: -1 do:
                [ : index |  | units |
                units := 1000 raisedTo: index.
                self > units ifTrue: [ ^ ((self / units) asFloat roundTo: 0.01)
asString, (suffixes at: index) ] ].
        ^ self asString



On Sat, Jun 12, 2010 at 10:03 AM,  <[hidden email]> wrote:

> Hi there,
>
> I've published a package to help printing measures of bytes in a human readable fashion.
>
> Here is is:
> http://www.squeaksource.com/Bytes
>
> Examples:
>
>        2 gigabytes asMegabyteString "will give you '2048 MB' if you print it"
>
> for those who have stored half of the galaxy its range goes from kilo to yatto
>
> enjoy
>
> sebastian
> PS: it uses Aconcagua as foundation so be sure to install it first
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project