Signed-off-by: Tim Speetjens <tim.speetjens@gmail.com>
···
--- lib/core_extensions.rb | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)diff --git a/lib/core_extensions.rb b/lib/core_extensions.rb
index 6b3d70f…5c3f3c9 100644
— a/lib/core_extensions.rb
+++ b/lib/core_extensions.rb
@@ -73,7 +73,7 @@ end
class String
def to_gb
begin
-
value,unit=self.match(/(\d+|.+) ([KMG]B)$/i)[1..2]
-
value,f,unit=self.match(/(\d+(\.\d+)?) ?(([KMG]B?|B))$/i)[1..3] case unit.to_sym when nil, :B, :byte then (value.to_f / 1000_000_000) when :GB, :G, :gigabyte then value.to_f
@@ -82,7 +82,7 @@ class String
else raise "Unknown unit: #{unit.inspect}!"
end
rescue
-
raise "Unknown string"
-
endraise "Unknown string: #{self.inspect}!"
end
end
–
1.7.2.5