<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>Class: Range</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />

    <script language="JavaScript" type="text/javascript">
    // <![CDATA[

        function toggleSource( id )
        {
          var elem
          var link

          if( document.getElementById )
          {
            elem = document.getElementById( id )
            link = document.getElementById( "l_" + id )
          }
          else if ( document.all )
          {
            elem = eval( "document.all." + id )
            link = eval( "document.all.l_" + id )
          }
          else
            return false;

          if( elem.style.display == "block" )
          {
            elem.style.display = "none"
            link.innerHTML = "show source"
          }
          else
          {
            elem.style.display = "block"
            link.innerHTML = "hide source"
          }
        }

        function openCode( url )
        {
          window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
        }
      // ]]>
    </script>
  </head>

  <body>
  <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
  <td class="file-title"><span class="file-title-prefix">Class</span><br />Range</td>
  <td align="right">
    <table cellspacing="0" cellpadding="2">
      <tr valign="top">
        <td>In:</td>
        <td>
<a href="../files/lib/core/facets/range/overlap_rb.html">lib/core/facets/range/overlap.rb</a>
<a href="../files/lib/core/facets/range/combine_rb.html">lib/core/facets/range/combine.rb</a>
<a href="../files/lib/core/facets/range/to_r_rb.html">lib/core/facets/range/to_r.rb</a>
<a href="../files/lib/core/facets/range/within_rb.html">lib/core/facets/range/within.rb</a>
<a href="../files/lib/core/facets/range/overlap_rb.html">lib/core/facets/range/overlap.rb</a>
<a href="../files/lib/core/facets/range/combine_rb.html">lib/core/facets/range/combine.rb</a>
<a href="../files/lib/core/facets/range/to_r_rb.html">lib/core/facets/range/to_r.rb</a>
<a href="../files/lib/core/facets/range/within_rb.html">lib/core/facets/range/within.rb</a>
        </td>
      </tr>
    <tr>
      <td>Parent:</td>
      <td>
        <a href="Object.html">
Object
         </a>
     </td>
   </tr>
         </table>
        </td>
        </tr>
      </table>
 <!-- banner header -->

  <div id="bodyContent">
      <div id="content">




  <div class="sectiontitle">Methods</div>
  <ul>
  <li><a href="#M000009">combine</a></li>
  <li><a href="#M000002">combine</a></li>
  <li><a href="#M000010">combine</a></li>
  <li><a href="#M000003">combine</a></li>
  <li><a href="#M000001">overlap?</a></li>
  <li><a href="#M000008">overlap?</a></li>
  <li><a href="#M000011">to_r</a></li>
  <li><a href="#M000004">to_r</a></li>
  <li><a href="#M000012">to_range</a></li>
  <li><a href="#M000005">to_range</a></li>
  <li><a href="#M000007">umbrella</a></li>
  <li><a href="#M000014">umbrella</a></li>
  <li><a href="#M000013">within?</a></li>
  <li><a href="#M000006">within?</a></li>
  </ul>






<div class="sectiontitle">Public Class methods</div>
<div class="method">
  <div class="title">
    <a name="M000010"></a><b>combine</b>(*intervals)
  </div>
  <div class="description">
  <p>
Combine intervals.
</p>
<pre>
  Range.combine(1..2, 2..4)   #=&gt; [1..4]
  Range.combine(1..2, 3..4)   #=&gt; [1..2, 3..4]

  CREDIT: Trans
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000010_source')" id="l_M000010_source">show source</a> ]</p>
  <div id="M000010_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/combine.rb, line 23</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">combine</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">intervals</span>)
    <span class="ruby-identifier">intype</span> = <span class="ruby-identifier">intervals</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">class</span>
    <span class="ruby-identifier">result</span> = []

    <span class="ruby-identifier">intervals</span> = <span class="ruby-identifier">intervals</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
      [<span class="ruby-identifier">i</span>.<span class="ruby-identifier">first</span>, <span class="ruby-identifier">i</span>.<span class="ruby-identifier">last</span>]
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-identifier">intervals</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)<span class="ruby-operator">|</span>  <span class="ruby-comment cmt">#inject([]) do |result,</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">from</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>]
        <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>]
      <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">to</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>]
        <span class="ruby-identifier">result</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>] = <span class="ruby-identifier">to</span>
      <span class="ruby-keyword kw">end</span>
      <span class="ruby-comment cmt">#result</span>
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">intype</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">Range</span>
      <span class="ruby-identifier">result</span>.<span class="ruby-identifier">collect</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> ((<span class="ruby-identifier">i</span>.<span class="ruby-identifier">first</span>)<span class="ruby-operator">..</span>(<span class="ruby-identifier">i</span>.<span class="ruby-identifier">last</span>)) }
    <span class="ruby-keyword kw">else</span>
      <span class="ruby-identifier">result</span>
    <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000003"></a><b>combine</b>(*intervals)
  </div>
  <div class="description">
  <p>
Combine intervals.
</p>
<pre>
  Range.combine(1..2, 2..4)   #=&gt; [1..4]
  Range.combine(1..2, 3..4)   #=&gt; [1..2, 3..4]

  CREDIT: Trans
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000003_source')" id="l_M000003_source">show source</a> ]</p>
  <div id="M000003_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/combine.rb, line 23</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">combine</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">intervals</span>)
    <span class="ruby-identifier">intype</span> = <span class="ruby-identifier">intervals</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">class</span>
    <span class="ruby-identifier">result</span> = []

    <span class="ruby-identifier">intervals</span> = <span class="ruby-identifier">intervals</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
      [<span class="ruby-identifier">i</span>.<span class="ruby-identifier">first</span>, <span class="ruby-identifier">i</span>.<span class="ruby-identifier">last</span>]
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-identifier">intervals</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)<span class="ruby-operator">|</span>  <span class="ruby-comment cmt">#inject([]) do |result,</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">from</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>]
        <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>]
      <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">to</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>]
        <span class="ruby-identifier">result</span>.<span class="ruby-identifier">last</span>[<span class="ruby-value">1</span>] = <span class="ruby-identifier">to</span>
      <span class="ruby-keyword kw">end</span>
      <span class="ruby-comment cmt">#result</span>
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">intype</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">Range</span>
      <span class="ruby-identifier">result</span>.<span class="ruby-identifier">collect</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> ((<span class="ruby-identifier">i</span>.<span class="ruby-identifier">first</span>)<span class="ruby-operator">..</span>(<span class="ruby-identifier">i</span>.<span class="ruby-identifier">last</span>)) }
    <span class="ruby-keyword kw">else</span>
      <span class="ruby-identifier">result</span>
    <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="sectiontitle">Public Instance methods</div>
<div class="method">
  <div class="title">
    <a name="M000009"></a><b>combine</b>(*intervals)
  </div>
  <div class="description">
  <p>
Combine ranges.
</p>
<pre>
  (1..2).combine(2..4)   #=&gt; [1..4]
  (1..2).combine(3..4)   #=&gt; [1..2, 3..4]

  TODO: Incorporate end-sentinal inclusion vs. exclusion.

  CREDIT: Trans
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000009_source')" id="l_M000009_source">show source</a> ]</p>
  <div id="M000009_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/combine.rb, line 12</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">combine</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">intervals</span>)
    <span class="ruby-constant">Range</span>.<span class="ruby-identifier">combine</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">intervals</span>)
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000002"></a><b>combine</b>(*intervals)
  </div>
  <div class="description">
  <p>
Combine ranges.
</p>
<pre>
  (1..2).combine(2..4)   #=&gt; [1..4]
  (1..2).combine(3..4)   #=&gt; [1..2, 3..4]

  TODO: Incorporate end-sentinal inclusion vs. exclusion.

  CREDIT: Trans
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show source</a> ]</p>
  <div id="M000002_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/combine.rb, line 12</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">combine</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">intervals</span>)
    <span class="ruby-constant">Range</span>.<span class="ruby-identifier">combine</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">intervals</span>)
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000001"></a><b>overlap?</b>(other)
  </div>
  <div class="description">
  <p>
Do two ranges <a href="Range.html#M000001">overlap?</a>
</p>
<pre>
  CREDIT: Daniel Schierbeck
  CREDIT: Brandon Keepers
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show source</a> ]</p>
  <div id="M000001_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/overlap.rb, line 8</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">overlap?</span>(<span class="ruby-identifier">other</span>)
    <span class="ruby-identifier">include?</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">first</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">first</span>)
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000008"></a><b>overlap?</b>(other)
  </div>
  <div class="description">
  <p>
Do two ranges <a href="Range.html#M000001">overlap?</a>
</p>
<pre>
  CREDIT: Daniel Schierbeck
  CREDIT: Brandon Keepers
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">show source</a> ]</p>
  <div id="M000008_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/overlap.rb, line 8</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">overlap?</span>(<span class="ruby-identifier">other</span>)
    <span class="ruby-identifier">include?</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">first</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">first</span>)
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000011"></a><b>to_r</b>()
  </div>
  <div class="description">
  <p>
A thing really should know itself. This simply returns <em>self</em>.
</p>
<p>
CREDIT: Trans
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000011_source')" id="l_M000011_source">show source</a> ]</p>
  <div id="M000011_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/to_r.rb, line 8</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_r</span>
    <span class="ruby-keyword kw">self</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000004"></a><b>to_r</b>()
  </div>
  <div class="description">
  <p>
A thing really should know itself. This simply returns <em>self</em>.
</p>
<p>
CREDIT: Trans
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show source</a> ]</p>
  <div id="M000004_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/to_r.rb, line 8</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_r</span>
    <span class="ruby-keyword kw">self</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000012"></a><b>to_range</b>()
  </div>
  <div class="description">
  <p>
A thing really should know itself. This simply returns <em>self</em>.
</p>
<p>
Note: This does not internally effect the Ruby interpretor such that it can
coerce <a href="Range.html">Range</a>-like objects into a <a
href="Range.html">Range</a>.
</p>
<p>
CREDIT: Trans
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000012_source')" id="l_M000012_source">show source</a> ]</p>
  <div id="M000012_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/to_r.rb, line 21</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_range</span>
    <span class="ruby-keyword kw">self</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000005"></a><b>to_range</b>()
  </div>
  <div class="description">
  <p>
A thing really should know itself. This simply returns <em>self</em>.
</p>
<p>
Note: This does not internally effect the Ruby interpretor such that it can
coerce <a href="Range.html">Range</a>-like objects into a <a
href="Range.html">Range</a>.
</p>
<p>
CREDIT: Trans
</p>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000005_source')" id="l_M000005_source">show source</a> ]</p>
  <div id="M000005_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/to_r.rb, line 21</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_range</span>
    <span class="ruby-keyword kw">self</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000007"></a><b>umbrella</b>(r)
  </div>
  <div class="description">
  <p>
Returns a two element array of the relationship between two Ranges.
</p>
<p>
Diagram:
</p>
<pre>
    Relationship     Returns

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

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

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

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

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

  etc.
</pre>
<p>
Example:
</p>
<pre>
  (0..3).umbrella(1..2)  #=&gt;  [-1,-1]

  CREDIT: Trans
  CREDIT: Chris Kappler
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000007_source')" id="l_M000007_source">show source</a> ]</p>
  <div id="M000007_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/within.rb, line 50</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">umbrella</span>(<span class="ruby-identifier">r</span>)
    <span class="ruby-identifier">s</span> = <span class="ruby-identifier">first</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">first</span>
    <span class="ruby-identifier">e</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">last</span>

    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">exclude_end?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">exclude_end?</span>
        <span class="ruby-identifier">e</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">max</span>
      <span class="ruby-keyword kw">else</span>
        <span class="ruby-identifier">e</span> = (<span class="ruby-identifier">r</span>.<span class="ruby-identifier">exclude_end?</span> <span class="ruby-value">? </span><span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&lt;=&gt;</span> (<span class="ruby-identifier">exclude_end?</span> <span class="ruby-value">? </span><span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-value">1</span>)
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>,<span class="ruby-identifier">e</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000014"></a><b>umbrella</b>(r)
  </div>
  <div class="description">
  <p>
Returns a two element array of the relationship between two Ranges.
</p>
<p>
Diagram:
</p>
<pre>
    Relationship     Returns

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

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

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

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

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

  etc.
</pre>
<p>
Example:
</p>
<pre>
  (0..3).umbrella(1..2)  #=&gt;  [-1,-1]

  CREDIT: Trans
  CREDIT: Chris Kappler
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000014_source')" id="l_M000014_source">show source</a> ]</p>
  <div id="M000014_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/within.rb, line 50</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">umbrella</span>(<span class="ruby-identifier">r</span>)
    <span class="ruby-identifier">s</span> = <span class="ruby-identifier">first</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">first</span>
    <span class="ruby-identifier">e</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">last</span>

    <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">exclude_end?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">exclude_end?</span>
        <span class="ruby-identifier">e</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">max</span>
      <span class="ruby-keyword kw">else</span>
        <span class="ruby-identifier">e</span> = (<span class="ruby-identifier">r</span>.<span class="ruby-identifier">exclude_end?</span> <span class="ruby-value">? </span><span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&lt;=&gt;</span> (<span class="ruby-identifier">exclude_end?</span> <span class="ruby-value">? </span><span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-value">1</span>)
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span>

    <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>,<span class="ruby-identifier">e</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000013"></a><b>within?</b>(rng)
  </div>
  <div class="description">
  <p>
Uses the <a href="Range.html#M000007">Range#umbrella</a> method to
determine if another <a href="Range.html">Range</a> is <em>anywhere</em>
within this <a href="Range.html">Range</a>.
</p>
<pre>
  (1..3).within?(0..4)  #=&gt; true

  CREDIT: Trans
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000013_source')" id="l_M000013_source">show source</a> ]</p>
  <div id="M000013_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/within.rb, line 10</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">within?</span>(<span class="ruby-identifier">rng</span>)
    <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">rng</span>.<span class="ruby-identifier">umbrella</span>(<span class="ruby-keyword kw">self</span>)
    <span class="ruby-keyword kw">when</span> [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>], [<span class="ruby-value">-1</span>,<span class="ruby-value">0</span>], [<span class="ruby-value">0</span>,<span class="ruby-value">-1</span>], [<span class="ruby-value">-1</span>,<span class="ruby-value">-1</span>]
      <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
    <span class="ruby-keyword kw">else</span>
      <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
    <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
<div class="method">
  <div class="title">
    <a name="M000006"></a><b>within?</b>(rng)
  </div>
  <div class="description">
  <p>
Uses the <a href="Range.html#M000007">Range#umbrella</a> method to
determine if another <a href="Range.html">Range</a> is <em>anywhere</em>
within this <a href="Range.html">Range</a>.
</p>
<pre>
  (1..3).within?(0..4)  #=&gt; true

  CREDIT: Trans
</pre>
  </div>
<div class="sourcecode">
  <p class="source-link">[ <a href="javascript:toggleSource('M000006_source')" id="l_M000006_source">show source</a> ]</p>
  <div id="M000006_source" class="dyn-source">
<pre>
<span class="ruby-comment cmt"># File lib/core/facets/range/within.rb, line 10</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">within?</span>(<span class="ruby-identifier">rng</span>)
    <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">rng</span>.<span class="ruby-identifier">umbrella</span>(<span class="ruby-keyword kw">self</span>)
    <span class="ruby-keyword kw">when</span> [<span class="ruby-value">0</span>,<span class="ruby-value">0</span>], [<span class="ruby-value">-1</span>,<span class="ruby-value">0</span>], [<span class="ruby-value">0</span>,<span class="ruby-value">-1</span>], [<span class="ruby-value">-1</span>,<span class="ruby-value">-1</span>]
      <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
    <span class="ruby-keyword kw">else</span>
      <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
    <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span>
</pre>
  </div>
</div>
</div>
</div>

  </div>

    </body>
</html>