File size output helper
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
tasks
test
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

PrettyFileSize
==============

Allows to print file size (given in bytes) in very pretty way.

Example
=======

pretty_file_size(1023) => '1023 b'
pretty_file_size(1024) => '1 Kb'

pretty_file_size(123.123) => '123.12 b'
pretty_file_size(123.123 :accuracy => 3) => '123.123 b'

pretty_file_size(1024) do |size, unit|
  # size = 1 unit = " Mb"
  "Size is " + size + " and the unit is" + unit
end => "Size is 1 and the unit is Mb"

pretty_file_size(1024, :names => { :kb => " Kilobyte" }) => '1 Kilobyte'


Copyright (c) 2010 Olexiy Zamkoviy, released under the MIT license