Class: Float

Inherits:
Object show all
Defined in:
lib/range_extd/numeric.rb

Overview

class Float

The same as Numeric#> and Numeric#<. See them for the background.

Instance Method Summary collapse

Instance Method Details

#<(c) ⇒ Object

Special case for comparison with a RangeExtd::Infinity instance.



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/range_extd/numeric.rb', line 101

def <(c)
  # Default if self is Complex or something not Integer, Rational, Float or alike
  # or the special case INFINITY.
  return less_than_float_before_infinity?(c) if ((abs rescue self) == Float::INFINITY)

  if RangeExtd::Infinity.infinity? c
    c.positive?
  else
    less_than_float_before_infinity?(c)
  end
end

#<=>(c) ⇒ Object

Special case for comparison with a RangeExtd::Infinity instance.



75
76
77
78
79
80
81
# File 'lib/range_extd/numeric.rb', line 75

def <=>(c)
  # Default if the special case INFINITY.
  return compare_than_float_before_infinity?(c) if ((abs rescue self) == Float::INFINITY)

  return (-(c.send(__method__, self) || return)) if RangeExtd::Infinity.infinity? c
  compare_than_float_before_infinity?(c)
end

#>(c) ⇒ Object

Special case for comparison with a RangeExtd::Infinity instance.



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/range_extd/numeric.rb', line 86

def >(c)
  # Default if self is Complex or something not Integer, Rational, Float or alike
  # or the special case INFINITY.
  return greater_than_float_before_infinity?(c) if ((abs rescue self) == Float::INFINITY)

  if RangeExtd::Infinity.infinity? c
    c.negative?
  else
    greater_than_float_before_infinity?(c)
  end
end

#compare_than_float_before_infinity?Object

Backup of the original #<=>



73
# File 'lib/range_extd/numeric.rb', line 73

alias_method :compare_than_float_before_infinity?, :<=>

#greater_than_float_before_infinity?Object

Backup of the original #>



84
# File 'lib/range_extd/numeric.rb', line 84

alias_method :greater_than_float_before_infinity?, :>

#less_than_float_before_infinity?Object

Backup of the original #<



99
# File 'lib/range_extd/numeric.rb', line 99

alias_method :less_than_float_before_infinity?, :<