Comparable

A mix-in for classes allowing relational operations. Classes including this module must define the basic relational operators <=>. All other relational operators can be derived through use of those definitions.

Methods

self == other

Returns true if self and other are equal.

Returns nil if <=> returns nil.

self > other

Returns true if self is greater than other.

If <=> returns nil, throws an ArgumentError exception.

self >= other

Returns true if self is greater than or equal to other.

If <=> returns nil, throws an ArgumentError exception.

self < other

Returns true if self is less than other.

If <=> returns nil, throws an ArgumentError exception.

self <= other

Returns true if self is less than or equal to other.

If <=> returns nil, throws an ArgumentError exception.

between?(min, max)

Returns true if self falls within a range from min to max, inclusive.

If self <=> min or self <=> max returns nil, throws an ArgumentError exception.