Class: Numeric

Inherits:
Object show all
Defined in:
lib/backports/1.9.1/numeric/round.rb,
lib/backports/2.3.0/numeric/negative.rb,
lib/backports/2.3.0/numeric/positive.rb

Instance Method Summary collapse

Instance Method Details

#negative?Boolean

Returns:

  • (Boolean)

3
4
5
# File 'lib/backports/2.3.0/numeric/negative.rb', line 3

def negative?
  self < 0
end

#positive?Boolean

Returns:

  • (Boolean)

3
4
5
# File 'lib/backports/2.3.0/numeric/positive.rb', line 3

def positive?
  self > 0
end

#round_with_digits(ndigits = 0) ⇒ Object


6
7
8
9
# File 'lib/backports/1.9.1/numeric/round.rb', line 6

def round_with_digits(ndigits=0)
  ndigits = Backports::coerce_to_int(ndigits)
  ndigits.zero? ? round_without_digits : Float(self).round(ndigits)
end