Class: Date::Infinity
- Inherits:
-
Numeric
- Object
- Numeric
- Date::Infinity
- Includes:
- Comparable
- Defined in:
- lib/rubysl/date/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.
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 |
#abs ⇒ Object
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
266 |
# File 'lib/rubysl/date/date.rb', line 266 def finite? () false end |
#infinite? ⇒ Boolean
267 |
# File 'lib/rubysl/date/date.rb', line 267 def infinite? () d.nonzero? end |
#nan? ⇒ Boolean
268 |
# File 'lib/rubysl/date/date.rb', line 268 def nan? () d.zero? end |
#zero? ⇒ Boolean
265 |
# File 'lib/rubysl/date/date.rb', line 265 def zero? () false end |