Class | InfinityClass
In: | lib/facets/more/infinity.rb
Parent: | Numeric

# Infinity

A full featured Infinity class, supporting signed direction. Inifinty is a multiton based on direction The constant INFINITY is provided as the common case with direction=+1 (positive).

## Usage

      NaN
      Inf
      PosInf
      NegInf

These four constants a built from two other basic constants:

      UNDEFINED
      INFINITY

In physical memory there are actually only three objects, namely three instances of InfinityClass, one for NaN, PosInf and NegInf, respectively.

### Methods

+@ -@ <=> == coerce new times to_f to_s

### Included Modules

Multiton

### Classes and Modules

Class InfinityClass::Numeric

### Constants

UNDEFINED | = | InfinityClass.instance(0) |  | Set constant to positive infinity.
INFINITY | = | InfinityClass.instance(1)
NaN | = | UNDEFINED
Inf | = | INFINITY
PosInf | = | +INFINITY
NegInf | = | -INFINITY

### Attributes

direction | [R] |

### Public Class methods

new(direction=1)

### Public Instance methods

+@()

Noop.

-@()

Change direction of infinity.

<=>(other)

Comparision where infinity is alway greatest and negative infinityalways least.

==(other)

Equality. Note that NaN != NaN.

coerce(other)

Coerce allows other numbers to be compared to infinity.

times() {|end| ...}

Gee, a real infinite loop!

to_f()

Convert to the float version of infinity.

to_s()

[Validate]