Module MusicBrainz::CoreExtensions::Range::Equality
In: lib/rbrainz/core_ext/range/equality.rb

Mixin module with equality operations for ranges. The built-in Range class is currently missing functions to compare a Range with another Range. There exist 13 disjoint equality operations for ranges. This mixin implements them all and a few extra operations for commonly used combinations.

Methods

Public Instance methods

<(b)

Alias for before?

a <= b is the same as a.before?(b) or a.meets_beginning_of?(b)

>(b)

Alias for after?

a >= b is the same as a.after?(b) or a.meets_end_of?(b)

a.after?(b) is true, if a begins after the end of b. Same as b.before?(a).

           |A------|
 |B------|

a.before?(b) is true, if a ends before the beginning of b. Same as b.after?(a).

 |A------|
           |B------|

a.between?(b) is the same as a.starts?(b) or a.during?(b) or a.finishes?(b)

a.contains?(b) is true, if b fits completely into a. Same as b.during?(a).

 |A------------|
    |B------|

a.during?(b) is true, if a fits completely into b. Same as b.contains?(a).

    |A------|
 |B------------|

a.finished_by?(b) is true, if a and b have the same end but b begins after a. Same as b.finishes?(a).

 |A-----------|
      |B------|

a.finishes?(b) is true, if a and b have the same end but a begins after b. Same as b.finished_by?(a).

      |A------|
 |B-----------|

a.meets_beginning_of?(b) is true, if b begins exactly at the end of a. Same as b.meets_end_of?(a).

 |A------|
         |B------|

a.meets_end_of?(b) is true, if b ends exactly at the beginning of a. Same as b.meets_beginning_of?(a).

         |A------|
 |B------|

a.overlaps_beginning_of?(b) is true, if a overlaps the beginning of b. Same as b.overlaps_end_of?(a).

 |A------|
      |B------|

a.overlaps_end_of?(b) is true, if a overlaps the end of b. Same as b.overlaps_beginning_of?(a).

      |A------|
 |B------|

a.started_by?(b) is true, if a and b have the same beginning but a lasts longer than b. Same as b.starts?(a).

 |A-----------|
 |B------|

a.starts?(b) is true, if a and b have the same beginning but b lasts longer than a. Same as b.started_by?(a).

 |A------|
 |B-----------|

[Validate]