Class | Range
In: | lib/core/facets/range/combine.rb lib/core/facets/range/overlap.rb lib/core/facets/range/to_r.rb lib/core/facets/range/within.rb lib/standard/facets/random.rb
Parent: | Object

### Methods

combine combine overlap? to_r to_range umbrella within?

### Included Modules

Random::RangeExtensions

### Public Class methods

combine(*intervals)

Combine intervals.

      Range.combine(1..2, 2..4)   #=> [1..4]
      Range.combine(1..2, 3..4)   #=> [1..2, 3..4]

CREDIT: Trans

### Public Instance methods

combine(*intervals)

Combine ranges.

      (1..2).combine(2..4)   #=> [1..4]
      (1..2).combine(3..4)   #=> [1..2, 3..4]

TODO: Incorporate end-sentinal inclusion vs. exclusion.

CREDIT: Trans

overlap?(other)

Do two ranges overlap?

CREDIT: Daniel Schierbeck, Brandon Keepers

to_r()

A thing really should know itself. This simply returns self.

CREDIT: Trans

to_range()

A thing really should know itself. This simply returns self.

Note: This does not internally effect the Ruby interpretor such that it can coerce Range-like objects into a Range.

CREDIT: Trans

umbrella(r)

Returns a two element array of the relationship between two Ranges.

Diagram …

        Relationship     Returns

      self |-----------|
      r    |-----------|    [0,0]

      self |-----------|
      r     |---------|     [-1,-1]

      self  |---------|
      r    |-----------|    [1,1]

      self |-----------|
      r     |----------|    [-1,0]

      self |-----------|
      r     |-----------|   [-1,1]

      etc.

Example:

      (0..3).umbrella(1..2)  #=>  [-1,-1]

CREDIT: Trans, Chris Kappler

within?(rng)

Uses the Range#umbrella method to determine if another Range is anywhere within this Range.

      (1..3).within?(0..4)  #=> true

CREDIT: Trans

[Validate]