Class: Date::Infinity
- Includes:
- Comparable
- Defined in:
- opal/stdlib/date/infinity.rb
Instance Attribute Summary collapse
-
#d ⇒ Object
readonly
Returns the value of attribute d.
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
- #to_f ⇒ Object
- #zero? ⇒ Boolean
Methods inherited from Numeric
Constructor Details
#initialize(d = 1) ⇒ Infinity
Returns a new instance of Infinity.
5 6 7
# File 'opal/stdlib/date/infinity.rb', line 5 def initialize(d = 1) @d = d <=> 0 end
Instance Attribute Details
#d ⇒ Object (readonly)
Returns the value of attribute d.
9 10 11
# File 'opal/stdlib/date/infinity.rb', line 9 def d @d end
Instance Method Details
#+@ ⇒ Object
35 36 37
# File 'opal/stdlib/date/infinity.rb', line 35 def +@ self.class.new(+d) end
#-@ ⇒ Object
31 32 33
# File 'opal/stdlib/date/infinity.rb', line 31 def -@ self.class.new(-d) end
#<=>(other) ⇒ Object
#abs ⇒ Object
27 28 29
# File 'opal/stdlib/date/infinity.rb', line 27 def abs self.class.new end
#coerce(other) ⇒ Object
55 56 57 58 59 60 61 62
# File 'opal/stdlib/date/infinity.rb', line 55 def coerce(other) case other when Numeric [-d, d] else super end end
#finite? ⇒ Boolean
Returns:
- (Boolean )
15 16 17
# File 'opal/stdlib/date/infinity.rb', line 15 def finite? false end
#infinite? ⇒ Boolean
Returns:
- (Boolean )
19 20 21
# File 'opal/stdlib/date/infinity.rb', line 19 def infinite? d.nonzero? end
#nan? ⇒ Boolean
Returns:
- (Boolean )
23 24 25
# File 'opal/stdlib/date/infinity.rb', line 23 def nan? d.zero? end