class Range

Public Instance Methods

<=>(other) click to toggle source
# File lib/better_ranges/sparse_range.rb, line 233
def <=>(other)
  comp = nil
  if other.is_a?(Range) || other.is_a?(BetterRanges::SparseRange)
    comp = (first <=> other.first)
    comp = (last <=> other.last) if comp == 0
    if comp == 0
      comp = -1 if exclude_end? && !other.exclude_end?
      comp = 1 if !exclude_end? && other.exclude_end?
    end
  else
    comp = (first <=> other)
    comp = (last <=> other) if comp == 0
    comp = -1 if comp == 0 && exclude_end?
  end
  comp
end