Ticket #7065: comments_for_bytes.diff
| File comments_for_bytes.diff, 1.6 kB (added by sethladd, 2 years ago) |
|---|
-
activesupport/lib/active_support/core_ext/numeric/bytes.rb
old new 1 1 module ActiveSupport #:nodoc: 2 2 module CoreExtensions #:nodoc: 3 3 module Numeric #:nodoc: 4 # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes 4 # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes. 5 5 module Bytes 6 # Returns +self+. 6 7 def bytes 7 8 self 8 9 end 9 10 alias :byte :bytes 10 11 12 # 1 kilobyte == 1024 bytes 11 13 def kilobytes 12 14 self * 1024 13 15 end 14 16 alias :kilobyte :kilobytes 15 17 18 # 1 megabyte == 1048576 (1024 ^ 2) bytes 16 19 def megabytes 17 20 self * 1024.kilobytes 18 21 end 19 22 alias :megabyte :megabytes 20 23 24 # 1 gigabyte == 1073741824 (1024 ^ 3) bytes 21 25 def gigabytes 22 26 self * 1024.megabytes 23 27 end 24 28 alias :gigabyte :gigabytes 25 29 30 # 1 terabyte == 1099511627776 (1024 ^ 4) bytes 26 31 def terabytes 27 32 self * 1024.gigabytes 28 33 end 29 34 alias :terabyte :terabytes 30 35 36 # 1 petabyte == 1125899906842624 (1024 ^ 5) bytes 31 37 def petabytes 32 38 self * 1024.terabytes 33 39 end 34 40 alias :petabyte :petabytes 35 41 42 # 1 exabyte == 1152921504606846976 (1024 ^ 6) bytes 36 43 def exabytes 37 44 self * 1024.petabytes 38 45 end