Convert bytes to a human readable string: 1337 → 1.34 kB
Useful for displaying file sizes for humans, Ported from sindresorhus/pretty-bytes
Installation
Add this line to your application's Gemfile:
gem 'pretty_bytes'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pretty_bytes
Usage
CLI
$ pretty-bytes help
Usage
$ pretty-bytes <number>
Example
$ pretty-bytes 1337
1.34 kB
API
require "pretty_bytes"
pb = PrettyBytes.new
pb.convert(1337) # => 1.34 kB