kibi 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/kibi/kibi.rb +26 -0
  2. metadata +2 -3
@@ -11,6 +11,10 @@ module Kibi
11
11
  [bytes.to_f / yobibyte, :yb]
12
12
  when bytes >= zebibyte
13
13
  [bytes.to_f / zebibyte, :zb]
14
+ when bytes >= exbibyte
15
+ [bytes.to_f / exbibyte, :eb]
16
+ when bytes >= pebibyte
17
+ [bytes.to_f / pebibyte, :pb]
14
18
  when bytes >= tebibyte
15
19
  [bytes.to_f / tebibyte, :tb]
16
20
  when bytes >= gibibyte
@@ -31,5 +35,27 @@ module Kibi
31
35
 
32
36
  humanize p.size
33
37
  end
38
+
39
+ def bytes_to bytes, unit
40
+ case unit
41
+ when :k, :kb, :kibibytes, :kilobytes
42
+ bytes.to_f / kibibyte
43
+ when :m, :mb, :mebibytes, :megabytes
44
+ bytes.to_f / mebibyte
45
+ when :g, :gb, :gibibytes, :gigabytes
46
+ bytes.to_f / gibibyte
47
+ when :t, :tb, :tebibytes, :terabytes
48
+ bytes.to_f / tebibyte
49
+ when :p, :pb, :pebibytes, :petabytes
50
+ bytes.to_f / pebibyte
51
+ when :e, :eb, :exbibytes, :exabytes
52
+ bytes.to_f / exbibyte
53
+ when :z, :zb, :zebibytes, :zettabytes
54
+ bytes.to_f / zebibyte
55
+ when :y, :yb, :yobibytes, :yottabytes
56
+ bytes.to_f / yobibyte
57
+ end
58
+ end
59
+
34
60
  end
35
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kibi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-30 00:00:00.000000000 Z
12
+ date: 2012-05-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -46,4 +46,3 @@ signing_key:
46
46
  specification_version: 3
47
47
  summary: byte units
48
48
  test_files: []
49
- has_rdoc: