Sha256: dd2b17571db16dd92152af7d2e0e8d6e5eaa2a79dd48682ffc6133dcf4833dcc

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

class Numeric

  def percent
    self / 100.0
  end

  def radians
    self
  end
  alias radian radians

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

  def pi
    self * Math::PI
  end

  def meters
    self
  end
  alias meter meters

  def in_meters
    self
  end

  def kilometers
    self * 1000.0
  end
  alias kilometer kilometers

  def in_kilometers
    self / 1.kilometer
  end

  def miles
    self * 1609.344
  end
  alias mile miles

  def in_miles
    self / 1.mile
  end

  def feet
    self / 3.28084
  end
  alias foot feet

  def in_feet
    self / 1.foot
  end

  def string_with_style(style=NSNumberFormatterDecimalStyle)
    if style.is_a? Symbol
      style = style.nsnumberstyle
    end
    NSNumberFormatter.localizedStringFromNumber(self, numberStyle:style)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sugarcube-0.16.2 lib/sugarcube/numeric.rb
sugarcube-0.16 lib/sugarcube/numeric.rb
sugarcube-0.15.5 lib/sugarcube/numeric.rb
sugarcube-0.15.3 lib/sugarcube/numeric.rb