Class: Date::Infinity

Inherits:
Numeric
  • Object
show all
Includes:
Comparable
Defined in:
lib/rubysl/date/date.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(d = 1) ⇒ Infinity

Returns a new instance of Infinity.



259
# File 'lib/rubysl/date/date.rb', line 259

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

Instance Method Details

#+@Object



273
# File 'lib/rubysl/date/date.rb', line 273

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

#-@Object



272
# File 'lib/rubysl/date/date.rb', line 272

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

#<=>(other) ⇒ Object



275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/rubysl/date/date.rb', line 275

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

#absObject



270
# File 'lib/rubysl/date/date.rb', line 270

def abs() self.class.new end

#coerce(other) ⇒ Object



289
290
291
292
293
294
295
# File 'lib/rubysl/date/date.rb', line 289

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

#finite?Boolean

Returns:

  • (Boolean)


266
# File 'lib/rubysl/date/date.rb', line 266

def finite? () false end

#infinite?Boolean

Returns:

  • (Boolean)


267
# File 'lib/rubysl/date/date.rb', line 267

def infinite? () d.nonzero? end

#nan?Boolean

Returns:

  • (Boolean)


268
# File 'lib/rubysl/date/date.rb', line 268

def nan? () d.zero? end

#zero?Boolean

Returns:

  • (Boolean)


265
# File 'lib/rubysl/date/date.rb', line 265

def zero? () false end