Class: Axiom::Types::Infinity
- Inherits:
- BasicObject
- Extended by:
- Comparable
- Defined in:
- lib/axiom/types/support/infinity.rb
Overview
Represent an infinite number
Direct Known Subclasses
Class Method Summary collapse
-
.<=>(other) ⇒ 0, 1
private
Test the number against infinity.
-
.coerce(other) ⇒ Array(Infinity, Infinity)
private
Coerce a number into an Infinity class for comparison.
-
.succ ⇒ Class<Infinity>
private
Return the next successive object, which is always self.
Class Method Details
.<=>(other) ⇒ 0, 1
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test the number against infinity
20 21 22 23 24 25 26 |
# File 'lib/axiom/types/support/infinity.rb', line 20 def self.<=>(other) case other when ::BigDecimal then 1 when number then 0 when ::Numeric, inverse.singleton_class then 1 end end |
.coerce(other) ⇒ Array(Infinity, Infinity)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Coerce a number into an Infinity class for comparison
35 36 37 38 39 40 41 42 43 |
# File 'lib/axiom/types/support/infinity.rb', line 35 def self.coerce(other) case other when ::BigDecimal then [inverse, self] when number then [self, self] when ::Numeric then [inverse, self] else raise ::TypeError, "#{other.class} cannot be coerced" end end |
.succ ⇒ Class<Infinity>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the next successive object, which is always self
50 51 52 |
# File 'lib/axiom/types/support/infinity.rb', line 50 def self.succ self end |