Class Range
In: lib/facet/range/within?.rb
lib/facet/range/umbrella.rb
lib/facet/range/to_r.rb
Parent: Object

Methods

to_r   to_range   umbrella   within?  

Public Instance methods

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

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.

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:

  require 'facet/range/umbrella'

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

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

  require 'facet/range/within?'

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

[Validate]