Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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  
    11module ActiveSupport #:nodoc: 
    22  module CoreExtensions #:nodoc: 
    33    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. 
    55      module Bytes 
     6        # Returns +self+. 
    67        def bytes 
    78          self 
    89        end 
    910        alias :byte :bytes 
    1011 
     12        # 1 kilobyte == 1024 bytes 
    1113        def kilobytes 
    1214          self * 1024 
    1315        end 
    1416        alias :kilobyte :kilobytes 
    1517 
     18        # 1 megabyte == 1048576 (1024 ^ 2) bytes 
    1619        def megabytes 
    1720          self * 1024.kilobytes 
    1821        end 
    1922        alias :megabyte :megabytes 
    2023 
     24        # 1 gigabyte == 1073741824 (1024 ^ 3) bytes 
    2125        def gigabytes 
    2226          self * 1024.megabytes  
    2327        end 
    2428        alias :gigabyte :gigabytes 
    2529 
     30        # 1 terabyte == 1099511627776 (1024 ^ 4) bytes 
    2631        def terabytes 
    2732          self * 1024.gigabytes 
    2833        end 
    2934        alias :terabyte :terabytes 
    3035         
     36        # 1 petabyte == 1125899906842624 (1024 ^ 5) bytes 
    3137        def petabytes 
    3238          self * 1024.terabytes 
    3339        end 
    3440        alias :petabyte :petabytes 
    3541         
     42        # 1 exabyte == 1152921504606846976 (1024 ^ 6) bytes 
    3643        def exabytes 
    3744          self * 1024.petabytes 
    3845        end