Class: Date::Infinity
- Inherits:
-
Numeric
- Object
- Numeric
- Date::Infinity
- Includes:
- Comparable
- Defined in:
- lib/project/date.rb
Overview
:nodoc:
Instance Method Summary collapse
- #+@ ⇒ Object
- #-@ ⇒ Object
- #<=>(other) ⇒ Object
- #abs ⇒ Object
- #coerce(other) ⇒ Object
- #finite? ⇒ Boolean
- #infinite? ⇒ Boolean
-
#initialize(d = 1) ⇒ Infinity
constructor
A new instance of Infinity.
- #nan? ⇒ Boolean
- #zero? ⇒ Boolean
Constructor Details
#initialize(d = 1) ⇒ Infinity
Returns a new instance of Infinity.
257 |
# File 'lib/project/date.rb', line 257 def initialize(d=1) @d = d <=> 0 end |
Instance Method Details
#+@ ⇒ Object
271 |
# File 'lib/project/date.rb', line 271 def +@ () self.class.new(+d) end |
#-@ ⇒ Object
270 |
# File 'lib/project/date.rb', line 270 def -@ () self.class.new(-d) end |
#<=>(other) ⇒ Object
273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/project/date.rb', line 273 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 ⇒ Object
268 |
# File 'lib/project/date.rb', line 268 def abs() self.class.new end |
#coerce(other) ⇒ Object
287 288 289 290 291 292 293 |
# File 'lib/project/date.rb', line 287 def coerce(other) case other when Numeric; return -d, d else super end end |
#finite? ⇒ Boolean
264 |
# File 'lib/project/date.rb', line 264 def finite? () false end |
#infinite? ⇒ Boolean
265 |
# File 'lib/project/date.rb', line 265 def infinite? () d.nonzero? end |
#nan? ⇒ Boolean
266 |
# File 'lib/project/date.rb', line 266 def nan? () d.zero? end |
#zero? ⇒ Boolean
263 |
# File 'lib/project/date.rb', line 263 def zero? () false end |