Sha256: ffc04af05426224a4f1130939f104227f9c0885a3f1e5b4e9eefb0dc98a33b65

Contents?: true

Size: 1.54 KB

Versions: 54

Compression:

Stored size: 1.54 KB

Contents

class Numeric

  def percent
    self / 100.0
  end

  def g
    self * 9.78033
  end

  def in_g
    self / 9.78033
  end

  def radians
    self
  end
  alias radian radians

  def in_radians
    self
  end

  def degrees
    self / 180.0 * Math::PI
  end
  alias degree degrees

  def in_degrees
    self * 180.0 / Math::PI
  end

  def pi
    self * Math::PI
  end

  def meters
    self
  end
  alias meter meters

  def in_meters
    self
  end

  def kilometers
    self * 1000.0  # 1000 m / km
  end
  alias kilometer kilometers

  def in_kilometers
    self / 1.kilometer
  end

  def miles
    self * 1609.344  # 1609.344 m / mi
  end
  alias mile miles

  def in_miles
    self / 1.mile
  end

  def feet
    self / 3.28084  # 3.28084 m / ft
  end
  alias foot feet

  def in_feet
    self / 1.foot
  end

  def bytes
    self
  end
  alias byte bytes

  def kilobytes
    self * 1024**1
  end
  alias kilobyte kilobytes

  def megabytes
    self * 1024**2
  end
  alias megabyte megabytes

  def gigabytes
    self * 1024**3
  end
  alias gigabyte gigabytes

  def terabytes
    self * 1024**4
  end
  alias terabyte terabytes

  def petabytes
    self * 1024**5
  end
  alias petabyte petabytes

  def exabytes
    self * 1024**6
  end
  alias exabyte exabytes

  def in_bytes
    self
  end

  def in_kilobytes
    self / 1024**1
  end

  def in_megabytes
    self / 1024**2
  end

  def in_gigabytes
    self / 1024**3
  end

  def in_terabytes
    self / 1024**4
  end

  def in_petabytes
    self / 1024**5
  end

  def in_exabytes
    self / 1024**6
  end

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.5.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.4.2 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.4.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.4.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.7 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.6 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.5 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.4 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.3 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.2 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.3.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.2.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.1.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.1.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.8 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.7 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.6 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.5 lib/all/sugarcube-numbers/numeric.rb