Class: Date::Infinity
Overview
Instance Method Summary
collapse
Methods included from Comparable
#<, #<=, #==, #>, #>=, #between?
Methods inherited from Numeric
#div, #divmod, #floor, #integer?, #modulo, #nonzero?, #remainder
Constructor Details
#initialize(d = 1) ⇒ Infinity
Returns a new instance of Infinity.
264
|
# File 'lib/date.rb', line 264
def initialize(d=1) @d = d <=> 0 end
|
Instance Method Details
#<=>(other) ⇒ Object
def -@ () self.class.new(-d) end
def +@ () self.class.new(+d) end
280
281
282
283
284
285
286
287
288
289
290
291
292
|
# File 'lib/date.rb', line 280
def <=> (other)
case other
when Infinity; d <=> other.d
when Numeric; d
else
begin
l, r = other.coerce(self)
return l <=> r
rescue NoMethodError
end
end
nil
end
|
275
|
# File 'lib/date.rb', line 275
def abs() self.class.new end
|
#coerce(other) ⇒ Object
294
295
296
297
298
299
300
|
# File 'lib/date.rb', line 294
def coerce(other)
case other
when Numeric; return -d, d
else
super
end
end
|
#finite? ⇒ Boolean
271
|
# File 'lib/date.rb', line 271
def finite? () false end
|
#infinite? ⇒ Boolean
272
|
# File 'lib/date.rb', line 272
def infinite? () d.nonzero? end
|
#nan? ⇒ Boolean
273
|
# File 'lib/date.rb', line 273
def nan? () d.zero? end
|
#zero? ⇒ Boolean
270
|
# File 'lib/date.rb', line 270
def zero? () false end
|