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-3.0.4 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.3 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.2 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-3.0.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.12.3 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.12.2 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.12.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.12.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.11.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.11.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.10.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.9.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.8.2 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.8.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.8.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.7.1 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.7.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.6.0 lib/all/sugarcube-numbers/numeric.rb
sugarcube-2.5.0 lib/all/sugarcube-numbers/numeric.rb