Module: Sorting::Smaller

Extended by:
Comparable
Defined in:
lib/sorting/smaller.rb

Overview

Note:

require 'sorting' loads this module

A value whose #<=> method will always compare as being the smaller value. Useful for defaultizing potentially nil values before comparing/sorting.

Examples:

age = person.age || Sorting::Smaller

See Also:

Class Method Summary collapse

Class Method Details

.<=>(other) ⇒ -1

Returns Comparison. Pretends this object is smaller and hence always returns -1

Returns:

  • (-1)

    Comparison. Pretends this object is smaller and hence always returns -1


24
25
26
# File 'lib/sorting/smaller.rb', line 24

def self.<=>(other)
  -1
end