Numeric

Numeric is the abstract class for numbers. In Ruby, operations are possible among different numerical classes.

Operations and comparison methods (+, -, *, /, <=>), etc. are defined in a subclass. For increased efficiency, methods identical to the Numeric method may also be redefined in a subclass.

Superclass

  • Object

Included Modules

  • Comparable

Methods

+ self

Returns self.

- self

Returns self, negated.

This method is defined by the binary operator - in 0 - self.

abs

Returns the absolute value of self.

ceil

Returns the smallest integer equal to or greater than self (i.e., the ceiling).

floor

Returns the largest integer that does not exceed self (i.e., the floor).

integer?

Returs true when self is an integer.

round

Returns the integer closest to self.

truncate

Discards the decimal point and all digits after it.

Last updated