123456789_123456789_123456789_123456789_123456789_

Class: Date::Infinity

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Numeric
Instance Chain:
self, Comparable, Numeric
Inherits: Numeric
Defined in: ext/date/lib/date.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(d = 1) ⇒ Infinity

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 13

def initialize(d=1) @d = d <=> 0 end

Instance Method Details

#+@

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 27

def +@() self.class.new(+d) end

#-@

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 26

def -@() self.class.new(-d) end

#<=>(other)

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 29

def <=>(other)
  case other
  when Infinity; return d <=> other.d
  when Numeric; return d
  else
    begin
      l, r = other.coerce(self)
      return l <=> r
    rescue NoMethodError
    end
  end
  nil
end

#abs

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 24

def abs() self.class.new end

#coerce(other)

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 43

def coerce(other)
  case other
  when Numeric; return -d, d
  else
    super
  end
end

#d (protected)

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 15

def d() @d end

#finite?Boolean

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 20

def finite?() false end

#infinite?Boolean

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 21

def infinite?() d.nonzero? end

#nan?Boolean

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 22

def nan?() d.zero? end

#to_f

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 51

def to_f
  return 0 if @d == 0
  if @d > 0
    Float::INFINITY
  else
    -Float::INFINITY
  end
end

#zero?Boolean

[ GitHub ]

  
# File 'ext/date/lib/date.rb', line 19

def zero?() false end