kibi 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kibi/kibi.rb +9 -1
- metadata +1 -1
data/lib/kibi/kibi.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'units'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
module Kibi
|
4
5
|
class << self
|
@@ -23,5 +24,12 @@ module Kibi
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
27
|
+
def humanize_file_size path
|
28
|
+
p = Pathname.new File.expand_path(path)
|
29
|
+
raise "File #{path} does not exist" unless p.exist?
|
30
|
+
raise "Path must be a file (#{path} is a directory)" if p.directory?
|
31
|
+
|
32
|
+
humanize p.size
|
33
|
+
end
|
26
34
|
end
|
27
|
-
end
|
35
|
+
end
|