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 24 def <=>(other) klass = self.class case other when BigDecimal then 1 when ->(arg) { arg == klass.number } then 0 when ::Numeric, klass.inverse then 1 end end
Coerce a number into an Infinity instance for comparison
@param [::Numeric] other
@return [Array(Infinity, Infinity)]
@api private
# File lib/axiom/types/support/infinity.rb, line 40 def coerce(other) case other when BigDecimal then [inverse, self] when self.class.number then [self, self] when ::Numeric then [inverse, self] else fail TypeError, "#{other.class} cannot be coerced" end end
Generated with the Darkfish Rdoc Generator 2.