Class: Date::Infinity
- Includes:
- Comparable
- Defined in:
- opal/stdlib/date.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
7 8 9
# File 'opal/stdlib/date.rb', line 7 def initialize(d = 1) @d = d <=> 0 end
Instance Attribute Details
#d ⇒ Object (readonly)
Returns the value of attribute d
11 12 13
# File 'opal/stdlib/date.rb', line 11 def d @d end
Instance Method Details
#+@ ⇒ Object
37 38 39
# File 'opal/stdlib/date.rb', line 37 def +@ self.class.new(+d) end
#-@ ⇒ Object
33 34 35
# File 'opal/stdlib/date.rb', line 33 def -@ self.class.new(-d) end
#<=>(other) ⇒ Object
#abs ⇒ Object
29 30 31
# File 'opal/stdlib/date.rb', line 29 def abs self.class.new end
#coerce(other) ⇒ Object
57 58 59 60 61 62 63 64
# File 'opal/stdlib/date.rb', line 57 def coerce(other) case other when Numeric [-d, d] else super end end
#finite? ⇒ Boolean
Returns:
- (Boolean )
17 18 19
# File 'opal/stdlib/date.rb', line 17 def finite? false end
#infinite? ⇒ Boolean
Returns:
- (Boolean )
21 22 23
# File 'opal/stdlib/date.rb', line 21 def infinite? d.nonzero? end
#nan? ⇒ Boolean
Returns:
- (Boolean )
25 26 27
# File 'opal/stdlib/date.rb', line 25 def nan? d.zero? end
#to_f ⇒ Object
66 67 68 69 70 71 72 73
# File 'opal/stdlib/date.rb', line 66 def to_f return 0 if @d == 0 if @d > 0 Float::INFINITY else -Float::INFINITY end end