Class: Integer
Overview
Instance Method Summary collapse
-
#<(c) ⇒ Object
Special case for comparison with a RangeExtd::Infinity instance.
-
#<=>(c) ⇒ Object
Special case for comparison with a RangeExtd::Infinity instance.
-
#>(c) ⇒ Object
Special case for comparison with a RangeExtd::Infinity instance.
-
#compare_than_integer_before_infinity? ⇒ Object
Backup of the original #<=>.
-
#greater_than_integer_before_infinity? ⇒ Object
Backup of the original #>.
-
#less_than_integer_before_infinity? ⇒ Object
Backup of the original #<.
Instance Method Details
#<(c) ⇒ Object
Special case for comparison with a RangeExtd::Infinity instance.
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/range_extd/numeric.rb', line 149 def <(c) # Default if self is not comparable (in case the Integer method is redifined by a user). return less_than_integer_before_infinity?(c) if !self.class.method_defined?(:>) if RangeExtd::Infinity.infinity? c c.positive? else less_than_integer_before_infinity?(c) end end |
#<=>(c) ⇒ Object
Special case for comparison with a RangeExtd::Infinity instance.
124 125 126 127 128 129 130 |
# File 'lib/range_extd/numeric.rb', line 124 def <=>(c) # Default if the special case INFINITY (never happens in Default, but a user may define Integer::INFINITY). return compare_than_integer_before_infinity?(c) if ((abs rescue self) == Float::INFINITY) return (-(c.send(__method__, self) || return)) if RangeExtd::Infinity.infinity? c compare_than_integer_before_infinity?(c) end |
#>(c) ⇒ Object
Special case for comparison with a RangeExtd::Infinity instance.
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/range_extd/numeric.rb', line 135 def >(c) # Default if self is not comparable (in case the Integer method is redifined by a user). return greater_than_integer_before_infinity?(c) if !self.class.method_defined?(:>) if RangeExtd::Infinity.infinity? c c.negative? else greater_than_integer_before_infinity?(c) end end |
#compare_than_integer_before_infinity? ⇒ Object
Backup of the original #<=>
122 |
# File 'lib/range_extd/numeric.rb', line 122 alias_method :compare_than_integer_before_infinity?, :<=> |