Skip to content

Instantly share code, notes, and snippets.

@mtunjic
Created January 1, 2012 13:53
Show Gist options
  • Select an option

  • Save mtunjic/1547384 to your computer and use it in GitHub Desktop.

Select an option

Save mtunjic/1547384 to your computer and use it in GitHub Desktop.
Numeric#bytes
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