Skip to content
This repository
Browse code

Added petabytes and exebytes to numeric extensions (closes #2397) [ti…

…mct@mac.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2746 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 0d52abfd0ea42ba8f9bac996378087be42b93917 1 parent fabf348
David Heinemeier Hansson authored October 26, 2005
2  activesupport/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Added petabytes and exebytes to numeric extensions #2397 [timct@mac.com]
  4
+
3 5
 * Added Time#end_of_month to accompany Time#beginning_of_month #2514 [Jens-Christian Fischer]
4 6
 
5 7
 
11  activesupport/lib/active_support/core_ext/numeric/bytes.rb
@@ -27,6 +27,17 @@ def terabytes
27 27
           self * 1024.gigabytes
28 28
         end
29 29
         alias :terabyte :terabytes
  30
+        
  31
+        def petabytes
  32
+          self * 1024.terabytes
  33
+        end
  34
+        alias :petabyte :petabytes
  35
+        
  36
+        def exabytes
  37
+          self * 1024.petabytes
  38
+        end
  39
+        alias :exabyte :exabytes
  40
+        
30 41
       end
31 42
     end
32 43
   end
4  activesupport/test/core_ext/numeric_ext_test.rb
@@ -46,7 +46,9 @@ def test_unit_in_terms_of_another
46 46
       1.kilobyte ** 4  =>   1.terabyte,
47 47
       1024.kilobytes + 2.megabytes =>   3.megabytes,
48 48
                    2.gigabytes / 4 => 512.megabytes,
49  
-      256.megabytes * 20 + 5.gigabytes => 10.gigabytes
  49
+      256.megabytes * 20 + 5.gigabytes => 10.gigabytes,
  50
+      1.kilobyte ** 5 => 1.petabyte,
  51
+      1.kilobyte ** 6 => 1.exabyte
50 52
     }
51 53
 
52 54
     relationships.each do |left, right|

0 notes on commit 0d52abf

Please sign in to comment.
Something went wrong with that request. Please try again.