Nov. 13th, 2011

juan_gandhi: (Default)
source
package com.twitter
package conversions

import com.twitter.util.StorageUnit

object storage {
  class RichWholeNumber(wrapped: Long) {
    require(wrapped >= 0, "Negative storage units are unsupported")

    def byte = bytes
    def bytes = new StorageUnit(wrapped)
    def kilobyte = kilobytes
    def kilobytes = new StorageUnit(wrapped * 1024)
    def megabyte = megabytes
    def megabytes = new StorageUnit(wrapped * 1024 * 1024)
    def gigabyte = gigabytes
    def gigabytes = new StorageUnit(wrapped * 1024 * 1024 * 1024)
    def terabyte = terabytes
    def terabytes = new StorageUnit(wrapped * 1024 * 1024 * 1024 * 1024)
    def petabyte = petabytes
    def petabytes = new StorageUnit(wrapped * 1024 * 1024 * 1024 * 1024 * 1024)

    def thousand = wrapped * 1000
    def million = wrapped * 1000 * 1000
    def billion = wrapped * 1000 * 1000 * 1000
  }

  implicit def intToStorageUnitableWholeNumber(i: Int) = new RichWholeNumber(i)
  implicit def longToStorageUnitableWholeNumber(l: Long) = new RichWholeNumber(l)
}

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

September 2025

S M T W T F S
 1 23456
78910111213
14151617181920
21222324252627
282930    

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 6th, 2025 04:23 am
Powered by Dreamwidth Studios