Represent an infinite number
Test the number against infinity
@param [Numeric, Infinity] other
@return [0]
returned if the other object is infinity
@return [1]
returned if the other object is something other than infinity
@api private
# File lib/axiom/types/support/infinity.rb, line 19 def self.<=>(other) case other when ::BigDecimal then 1 when ->(arg) { arg == number } then 0 when ::Numeric, inverse.singleton_class then 1 end end
Coerce a number into an Infinity class for comparison
@param [::Numeric] other
@return [Array(Infinity, Infinity)]
@api private
# File lib/axiom/types/support/infinity.rb, line 34 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
Return the next successive object, which is always self
@return [Class<Infinity>]
@api private
# File lib/axiom/types/support/infinity.rb, line 49 def self.succ self end
The inverse of infinity
@return [Class<NegativeInfinity>]
@api private
# File lib/axiom/types/support/infinity.rb, line 58 def self.inverse NegativeInfinity end
The numeric representation of infinity
@return [Float]
@api private
# File lib/axiom/types/support/infinity.rb, line 68 def self.number ::Float::INFINITY end