Methods
Public Instance methods
to_r()

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

# File lib/facets/core/range/to_r.rb, line 5
  def to_r
    self
  end
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.

# File lib/facets/core/range/to_range.rb, line 9
  def to_range
    self
  end
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]
# File lib/facets/core/range/umbrella.rb, line 31
  def umbrella(r)
    s = self.first <=> r.first
    e = r.last <=> self.last
    return s,e
  end
within?(rng)

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

  (1..3).within?(0..4)  #=> true
# File lib/facets/core/range/within.rb, line 10
  def within?(rng)
    case rng.umbrella(self)
    when [0,0], [-1,0], [0,-1], [-1,-1]
      return true
    else
      return false
    end
  end