Class: Float

Inherits:
Object show all
Defined in:
lib/range_extd/infinity/infinity.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.



544
545
546
547
548
549
550
551
552
553
554
# File 'lib/range_extd/infinity/infinity.rb', line 544

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.



520
521
522
523
524
525
526
# File 'lib/range_extd/infinity/infinity.rb', line 520

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.



530
531
532
533
534
535
536
537
538
539
540
# File 'lib/range_extd/infinity/infinity.rb', line 530

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

No overwriting.



518
# File 'lib/range_extd/infinity/infinity.rb', line 518

alias_method :compare_than_float_before_infinity?, :<=>

#greater_than_float_before_infinity?Object

No overwriting.



528
# File 'lib/range_extd/infinity/infinity.rb', line 528

alias_method :greater_than_float_before_infinity?, :>

#less_than_float_before_infinity?Object

No overwriting.



542
# File 'lib/range_extd/infinity/infinity.rb', line 542

alias_method :less_than_float_before_infinity?, :<