Created
January 1, 2012 13:53
-
-
Save mtunjic/1547384 to your computer and use it in GitHub Desktop.
Numeric#bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Numeric | |
| KILOBYTE = 1024 | |
| MEGABYTE = KILOBYTE * 1024 | |
| GIGABYTE = MEGABYTE * 1024 | |
| def bytes | |
| self | |
| end | |
| alias :byte :bytes | |
| def kilobytes | |
| self * KILOBYTE | |
| end | |
| alias :kilobyte :kilobytes | |
| def megabytes | |
| self * MEGABYTE | |
| end | |
| alias :megabyte :megabytes | |
| def gigabytes | |
| self * GIGABYTE | |
| end | |
| alias :gigabyte :gigabytes | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment