~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
module ActiveSupport #:nodoc:
2
 
  module CoreExtensions #:nodoc:
3
 
    module Numeric #:nodoc:
4
 
      # Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
5
 
      module Bytes
6
 
        KILOBYTE = 1024
7
 
        MEGABYTE = KILOBYTE * 1024
8
 
        GIGABYTE = MEGABYTE * 1024
9
 
        TERABYTE = GIGABYTE * 1024
10
 
        PETABYTE = TERABYTE * 1024
11
 
        EXABYTE  = PETABYTE * 1024
12
 
 
13
 
        def bytes
14
 
          self
15
 
        end
16
 
        alias :byte :bytes
17
 
 
18
 
        def kilobytes
19
 
          self * KILOBYTE
20
 
        end
21
 
        alias :kilobyte :kilobytes
22
 
 
23
 
        def megabytes
24
 
          self * MEGABYTE
25
 
        end
26
 
        alias :megabyte :megabytes
27
 
 
28
 
        def gigabytes
29
 
          self * GIGABYTE
30
 
        end
31
 
        alias :gigabyte :gigabytes
32
 
 
33
 
        def terabytes
34
 
          self * TERABYTE
35
 
        end
36
 
        alias :terabyte :terabytes
37
 
 
38
 
        def petabytes
39
 
          self * PETABYTE
40
 
        end
41
 
        alias :petabyte :petabytes
42
 
 
43
 
        def exabytes
44
 
          self * EXABYTE
45
 
        end
46
 
        alias :exabyte :exabytes
47
 
      end
48
 
    end
49
 
  end
50
 
end