Sha256: 675fb9314cdfe680bb651da31c653496803f22802932af1241fe78740392e39e
Contents?: true
Size: 1.77 KB
Versions: 3
Compression:
Stored size: 1.77 KB
Contents
#:title: Infinity #-- # Infinity # v 0.9 # # Copyright (c) 2004,2005 Thomas Sawyer # # Ruby License # # This module is free software. You may use, modify, and/or redistribute this # software under the same terms as Ruby. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. # # # $Id: infinity.rb,v 0.9 2005/04/28 17:00:24 transami Exp $ # # ========================================================================== # Revision History :: # YYYY.MM.DD Ver. Dev. Description # -------------------------------------------------------------------------- # 2005.04.28 0.9 Trans * Minor modifications to documentation. # ========================================================================== #++ # = Description # # A full featured Infinity class, supporting aleph levels and signed # direction. Inifinty is a multiton based on the aleph and direction # values. The conastant INFINITY is provided as the common case with # aleph=0 and direction=+1 (positive). # # = Author(s) # # * Thomas Sawyer # require 'facet/multiton' class Infinity < Numeric VERSION = '0.9.0' include Multiton def self.[](a) self.new(a) end attr_reader :aleph, :direction def initialize(aleph=0, direction=1) @aleph = aleph @direction = direction end def -@ self.class.instance(@aleph, @direction * -1) end def to_f (1.0/0) * @direction end def times loop do yield end end def <=>(x) return (x.kind_of?(Infinity) ? (@aleph <=> x.aleph) : @direction) end def to_s %Q{#{ '-' if @direction == -1 }Infinity[#{@aleph}]} end end # constant (for aleph=0) INFINITY = Infinity.instance
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-0.7.1 | lib/facet/infinity.rb |
facets-0.7.0 | lib/facet/infinity.rb |
facets-0.7.2 | lib/facet/infinity.rb |