doc/TaskJuggler/PropertyList.html in taskjuggler-0.0.8 vs doc/TaskJuggler/PropertyList.html in taskjuggler-0.0.9

- old
+ new

@@ -149,10 +149,12 @@ <li><a href="../TaskJuggler/AttributeBase.html">TaskJuggler::AttributeBase</a></li> <li><a href="../TaskJuggler/AttributeDefinition.html">TaskJuggler::AttributeDefinition</a></li> + <li><a href="../TaskJuggler/AttributeOverwrite.html">TaskJuggler::AttributeOverwrite</a></li> + <li><a href="../TaskJuggler/BatchProcessor.html">TaskJuggler::BatchProcessor</a></li> <li><a href="../TaskJuggler/Booking.html">TaskJuggler::Booking</a></li> <li><a href="../TaskJuggler/BookingListAttribute.html">TaskJuggler::BookingListAttribute</a></li> @@ -227,10 +229,12 @@ <li><a href="../TaskJuggler/HTMLGraphics.html">TaskJuggler::HTMLGraphics</a></li> <li><a href="../TaskJuggler/Interval.html">TaskJuggler::Interval</a></li> + <li><a href="../TaskJuggler/IntervalList.html">TaskJuggler::IntervalList</a></li> + <li><a href="../TaskJuggler/IntervalListAttribute.html">TaskJuggler::IntervalListAttribute</a></li> <li><a href="../TaskJuggler/JobInfo.html">TaskJuggler::JobInfo</a></li> <li><a href="../TaskJuggler/Journal.html">TaskJuggler::Journal</a></li> @@ -259,10 +263,12 @@ <li><a href="../TaskJuggler/LogicalExpression.html">TaskJuggler::LogicalExpression</a></li> <li><a href="../TaskJuggler/LogicalExpressionAttribute.html">TaskJuggler::LogicalExpressionAttribute</a></li> + <li><a href="../TaskJuggler/LogicalExpressionListAttribute.html">TaskJuggler::LogicalExpressionListAttribute</a></li> + <li><a href="../TaskJuggler/LogicalFlag.html">TaskJuggler::LogicalFlag</a></li> <li><a href="../TaskJuggler/LogicalFunction.html">TaskJuggler::LogicalFunction</a></li> <li><a href="../TaskJuggler/LogicalOperation.html">TaskJuggler::LogicalOperation</a></li> @@ -539,10 +545,12 @@ <li><a href="../TaskJuggler/VimSyntax.html">TaskJuggler::VimSyntax</a></li> <li><a href="../TaskJuggler/WebServer.html">TaskJuggler::WebServer</a></li> + <li><a href="../TaskJuggler/WelcomePage.html">TaskJuggler::WelcomePage</a></li> + <li><a href="../TaskJuggler/WorkingHours.html">TaskJuggler::WorkingHours</a></li> <li><a href="../TaskJuggler/WorkingHoursAttribute.html">TaskJuggler::WorkingHoursAttribute</a></li> <li><a href="../TaskJuggler/XMLBlob.html">TaskJuggler::XMLBlob</a></li> @@ -565,12 +573,10 @@ <li><a href="../RuntimeConfig.html">RuntimeConfig</a></li> <li><a href="../String.html">String</a></li> - <li><a href="../StringIO.html">StringIO</a></li> - </ul> <div id="no-class-search-results" style="display: none;">No matching classes.</div> </div> @@ -741,35 +747,35 @@ <div class="method-source-code" id="new-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 30</span> -30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-identifier">copyItems</span> = <span class="ruby-keyword kw">true</span>) -31: <span class="ruby-ivar">@items</span> = <span class="ruby-identifier">copyItems</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">to_ary</span> <span class="ruby-operator">:</span> [] -32: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">PropertySet</span>) -33: <span class="ruby-comment cmt"># Create a PropertyList from the given PropertySet.</span> -34: <span class="ruby-ivar">@propertySet</span> = <span class="ruby-identifier">arg</span> -35: <span class="ruby-comment cmt"># To keep the list sorted, we may have to access Property attributes.</span> -36: <span class="ruby-comment cmt"># Pre-scheduling, we can only use static attributes. Post-scheduling,</span> -37: <span class="ruby-comment cmt"># we can include dynamic attributes as well. This query template will</span> -38: <span class="ruby-comment cmt"># be used to query attributes when it has been set. Otherwise the list</span> -39: <span class="ruby-comment cmt"># can only be sorted by static attributes.</span> -40: <span class="ruby-ivar">@query</span> = <span class="ruby-keyword kw">nil</span> -41: <span class="ruby-identifier">resetSorting</span> -42: <span class="ruby-identifier">addSortingCriteria</span>(<span class="ruby-value str">'seqno'</span>, <span class="ruby-keyword kw">true</span>, <span class="ruby-value">1</span>) -43: <span class="ruby-identifier">sort!</span> -44: <span class="ruby-keyword kw">else</span> -45: <span class="ruby-comment cmt"># Create a PropertyList from a given other PropertyList.</span> -46: <span class="ruby-ivar">@propertySet</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">propertySet</span> -47: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> -48: <span class="ruby-ivar">@sortingLevels</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">sortingLevels</span> -49: <span class="ruby-ivar">@sortingCriteria</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">sortingCriteria</span>.<span class="ruby-identifier">dup</span> -50: <span class="ruby-ivar">@sortingUp</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">sortingUp</span>.<span class="ruby-identifier">dup</span> -51: <span class="ruby-ivar">@scenarioIdx</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">scenarioIdx</span>.<span class="ruby-identifier">dup</span> -52: <span class="ruby-keyword kw">end</span> -53: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 31</span> +31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">arg</span>, <span class="ruby-identifier">copyItems</span> = <span class="ruby-keyword kw">true</span>) +32: <span class="ruby-ivar">@items</span> = <span class="ruby-identifier">copyItems</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">to_ary</span> <span class="ruby-operator">:</span> [] +33: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">PropertySet</span>) +34: <span class="ruby-comment cmt"># Create a PropertyList from the given PropertySet.</span> +35: <span class="ruby-ivar">@propertySet</span> = <span class="ruby-identifier">arg</span> +36: <span class="ruby-comment cmt"># To keep the list sorted, we may have to access Property attributes.</span> +37: <span class="ruby-comment cmt"># Pre-scheduling, we can only use static attributes. Post-scheduling,</span> +38: <span class="ruby-comment cmt"># we can include dynamic attributes as well. This query template will</span> +39: <span class="ruby-comment cmt"># be used to query attributes when it has been set. Otherwise the list</span> +40: <span class="ruby-comment cmt"># can only be sorted by static attributes.</span> +41: <span class="ruby-ivar">@query</span> = <span class="ruby-keyword kw">nil</span> +42: <span class="ruby-identifier">resetSorting</span> +43: <span class="ruby-identifier">addSortingCriteria</span>(<span class="ruby-value str">'seqno'</span>, <span class="ruby-keyword kw">true</span>, <span class="ruby-value">1</span>) +44: <span class="ruby-identifier">sort!</span> +45: <span class="ruby-keyword kw">else</span> +46: <span class="ruby-comment cmt"># Create a PropertyList from a given other PropertyList.</span> +47: <span class="ruby-ivar">@propertySet</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">propertySet</span> +48: <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">query</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span> +49: <span class="ruby-ivar">@sortingLevels</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">sortingLevels</span> +50: <span class="ruby-ivar">@sortingCriteria</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">sortingCriteria</span>.<span class="ruby-identifier">dup</span> +51: <span class="ruby-ivar">@sortingUp</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">sortingUp</span>.<span class="ruby-identifier">dup</span> +52: <span class="ruby-ivar">@scenarioIdx</span> = <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">scenarioIdx</span>.<span class="ruby-identifier">dup</span> +53: <span class="ruby-keyword kw">end</span> +54: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -806,23 +812,23 @@ <div class="method-source-code" id="append-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 84</span> -84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">append</span>(<span class="ruby-identifier">list</span>) -85: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span> -86: <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">node</span><span class="ruby-operator">|</span> -87: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">propertySet</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@propertySet</span> -88: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Fatal Error: All nodes must belong to the same PropertySet.&quot;</span> -89: <span class="ruby-keyword kw">end</span> -90: <span class="ruby-keyword kw">end</span> -91: <span class="ruby-keyword kw">end</span> -92: -93: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">list</span>) -94: <span class="ruby-identifier">sort!</span> -95: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 85</span> +85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">append</span>(<span class="ruby-identifier">list</span>) +86: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span> +87: <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">node</span><span class="ruby-operator">|</span> +88: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">propertySet</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@propertySet</span> +89: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Fatal Error: All nodes must belong to the same PropertySet.&quot;</span> +90: <span class="ruby-keyword kw">end</span> +91: <span class="ruby-keyword kw">end</span> +92: <span class="ruby-keyword kw">end</span> +93: +94: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">list</span>) +95: <span class="ruby-identifier">sort!</span> +96: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -852,17 +858,17 @@ <div class="method-source-code" id="index-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 146</span> -146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">index</span> -147: <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span> -148: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> -149: <span class="ruby-identifier">p</span>.<span class="ruby-identifier">set</span>(<span class="ruby-value str">'index'</span>, <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>) -150: <span class="ruby-keyword kw">end</span> -151: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 147</span> +147: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">index</span> +148: <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span> +149: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> +150: <span class="ruby-identifier">p</span>.<span class="ruby-identifier">set</span>(<span class="ruby-value str">'index'</span>, <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>) +151: <span class="ruby-keyword kw">end</span> +152: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -891,14 +897,14 @@ <div class="method-source-code" id="item-ndex-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 140</span> -140: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">itemIndex</span>(<span class="ruby-identifier">item</span>) -141: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">item</span>) -142: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 141</span> +141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">itemIndex</span>(<span class="ruby-identifier">item</span>) +142: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">item</span>) +143: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -929,14 +935,14 @@ <div class="method-source-code" id="method-missing-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 58</span> -58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">func</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">block</span>) -59: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">method</span>(<span class="ruby-identifier">func</span>).<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">block</span>) -60: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 59</span> +59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">func</span>, *<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">block</span>) +60: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">method</span>(<span class="ruby-identifier">func</span>).<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">args</span>, &amp;<span class="ruby-identifier">block</span>) +61: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -965,17 +971,17 @@ <div class="method-source-code" id="reset-orting-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 75</span> -75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resetSorting</span> -76: <span class="ruby-ivar">@sortingLevels</span> = <span class="ruby-value">0</span> -77: <span class="ruby-ivar">@sortingCriteria</span> = [] -78: <span class="ruby-ivar">@sortingUp</span> = [] -79: <span class="ruby-ivar">@scenarioIdx</span> = [] -80: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 76</span> +76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resetSorting</span> +77: <span class="ruby-ivar">@sortingLevels</span> = <span class="ruby-value">0</span> +78: <span class="ruby-ivar">@sortingCriteria</span> = [] +79: <span class="ruby-ivar">@sortingUp</span> = [] +80: <span class="ruby-ivar">@scenarioIdx</span> = [] +81: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1004,17 +1010,17 @@ <div class="method-source-code" id="set-orting-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 67</span> -67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setSorting</span>(<span class="ruby-identifier">modes</span>) -68: <span class="ruby-identifier">resetSorting</span> -69: <span class="ruby-identifier">modes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mode</span><span class="ruby-operator">|</span> -70: <span class="ruby-identifier">addSortingCriteria</span>(*<span class="ruby-identifier">mode</span>) -71: <span class="ruby-keyword kw">end</span> -72: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 68</span> +68: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setSorting</span>(<span class="ruby-identifier">modes</span>) +69: <span class="ruby-identifier">resetSorting</span> +70: <span class="ruby-identifier">modes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mode</span><span class="ruby-operator">|</span> +71: <span class="ruby-identifier">addSortingCriteria</span>(*<span class="ruby-identifier">mode</span>) +72: <span class="ruby-keyword kw">end</span> +73: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1043,44 +1049,44 @@ <div class="method-source-code" id="sort--source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 105</span> -105: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sort!</span> -106: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">treeMode?</span> -107: <span class="ruby-comment cmt"># Tree sorting is somewhat complex. It will be based on the 'tree'</span> -108: <span class="ruby-comment cmt"># attribute of the PropertyTreeNodes but we have to update them first</span> -109: <span class="ruby-comment cmt"># based on the other sorting criteria.</span> -110: -111: <span class="ruby-comment cmt"># Remove the tree sorting mode first.</span> -112: <span class="ruby-identifier">sc</span> = <span class="ruby-ivar">@sortingCriteria</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">0</span>) -113: <span class="ruby-identifier">su</span> = <span class="ruby-ivar">@sortingUp</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">0</span>) -114: <span class="ruby-identifier">si</span> = <span class="ruby-ivar">@scenarioIdx</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">0</span>) -115: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span> -116: -117: <span class="ruby-comment cmt"># Sort the list based on the rest of the modes.</span> -118: <span class="ruby-identifier">sortInternal</span> -119: <span class="ruby-comment cmt"># The update the 'index' attributes of the PropertyTreeNodes.</span> -120: <span class="ruby-identifier">index</span> -121: <span class="ruby-comment cmt"># An then the 'tree' attributes.</span> -122: <span class="ruby-identifier">indexTree</span> -123: -124: <span class="ruby-comment cmt"># Restore the 'tree' sorting mode again.</span> -125: <span class="ruby-ivar">@sortingCriteria</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">sc</span>) -126: <span class="ruby-ivar">@sortingUp</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">su</span>) -127: <span class="ruby-ivar">@scenarioIdx</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">si</span>) -128: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -129: -130: <span class="ruby-comment cmt"># Sort again, now based on the updated 'tree' attributes.</span> -131: <span class="ruby-identifier">sortInternal</span> -132: <span class="ruby-keyword kw">else</span> -133: <span class="ruby-identifier">sortInternal</span> -134: <span class="ruby-keyword kw">end</span> -135: <span class="ruby-comment cmt"># Update indexes.</span> -136: <span class="ruby-identifier">index</span> -137: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 106</span> +106: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sort!</span> +107: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">treeMode?</span> +108: <span class="ruby-comment cmt"># Tree sorting is somewhat complex. It will be based on the 'tree'</span> +109: <span class="ruby-comment cmt"># attribute of the PropertyTreeNodes but we have to update them first</span> +110: <span class="ruby-comment cmt"># based on the other sorting criteria.</span> +111: +112: <span class="ruby-comment cmt"># Remove the tree sorting mode first.</span> +113: <span class="ruby-identifier">sc</span> = <span class="ruby-ivar">@sortingCriteria</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">0</span>) +114: <span class="ruby-identifier">su</span> = <span class="ruby-ivar">@sortingUp</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">0</span>) +115: <span class="ruby-identifier">si</span> = <span class="ruby-ivar">@scenarioIdx</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-value">0</span>) +116: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span> +117: +118: <span class="ruby-comment cmt"># Sort the list based on the rest of the modes.</span> +119: <span class="ruby-identifier">sortInternal</span> +120: <span class="ruby-comment cmt"># The update the 'index' attributes of the PropertyTreeNodes.</span> +121: <span class="ruby-identifier">index</span> +122: <span class="ruby-comment cmt"># An then the 'tree' attributes.</span> +123: <span class="ruby-identifier">indexTree</span> +124: +125: <span class="ruby-comment cmt"># Restore the 'tree' sorting mode again.</span> +126: <span class="ruby-ivar">@sortingCriteria</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">sc</span>) +127: <span class="ruby-ivar">@sortingUp</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">su</span>) +128: <span class="ruby-ivar">@scenarioIdx</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">si</span>) +129: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +130: +131: <span class="ruby-comment cmt"># Sort again, now based on the updated 'tree' attributes.</span> +132: <span class="ruby-identifier">sortInternal</span> +133: <span class="ruby-keyword kw">else</span> +134: <span class="ruby-identifier">sortInternal</span> +135: <span class="ruby-keyword kw">end</span> +136: <span class="ruby-comment cmt"># Update indexes.</span> +137: <span class="ruby-identifier">index</span> +138: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1107,14 +1113,14 @@ <div class="method-source-code" id="to-ary-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 62</span> -62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_ary</span> -63: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">dup</span> -64: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 63</span> +63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_ary</span> +64: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">dup</span> +65: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1145,14 +1151,14 @@ <div class="method-source-code" id="tree-ode--source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 100</span> -100: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">treeMode?</span> -101: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'tree'</span> -102: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 101</span> +101: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">treeMode?</span> +102: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'tree'</span> +103: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1187,36 +1193,36 @@ <div class="method-source-code" id="add-orting-riteria-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 168</span> -168: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">addSortingCriteria</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-identifier">up</span>, <span class="ruby-identifier">scIdx</span>) -169: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">knownAttribute?</span>(<span class="ruby-identifier">criteria</span>) <span class="ruby-operator">||</span> -170: <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">hasQuery?</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-identifier">scIdx</span>) -171: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -172: <span class="ruby-node">&quot;Unknown attribute #{criteria} used for sorting criterium&quot;</span> -173: <span class="ruby-keyword kw">end</span> -174: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scIdx</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> -175: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">scenarioSpecific?</span>(<span class="ruby-identifier">criteria</span>) -176: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -177: <span class="ruby-node">&quot;Attribute #{criteria} is scenario specific.&quot;</span> <span class="ruby-operator">+</span> -178: <span class="ruby-value str">&quot;You must specify a scenario id.&quot;</span> -179: <span class="ruby-keyword kw">end</span> -180: <span class="ruby-keyword kw">else</span> -181: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">project</span>.<span class="ruby-identifier">scenario</span>(<span class="ruby-identifier">scIdx</span>).<span class="ruby-identifier">nil?</span> -182: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Unknown scenario index #{scIdx} used.&quot;</span> -183: <span class="ruby-keyword kw">end</span> -184: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">scenarioSpecific?</span>(<span class="ruby-identifier">criteria</span>) -185: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Attribute #{criteria} is not scenario specific&quot;</span> -186: <span class="ruby-keyword kw">end</span> -187: <span class="ruby-keyword kw">end</span> -188: <span class="ruby-ivar">@sortingCriteria</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">criteria</span>) -189: <span class="ruby-ivar">@sortingUp</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">up</span>) -190: <span class="ruby-ivar">@scenarioIdx</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">scIdx</span>) -191: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> -192: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 169</span> +169: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">addSortingCriteria</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-identifier">up</span>, <span class="ruby-identifier">scIdx</span>) +170: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">knownAttribute?</span>(<span class="ruby-identifier">criteria</span>) <span class="ruby-operator">||</span> +171: <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">hasQuery?</span>(<span class="ruby-identifier">criteria</span>, <span class="ruby-identifier">scIdx</span>) +172: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +173: <span class="ruby-node">&quot;Unknown attribute #{criteria} used for sorting criterium&quot;</span> +174: <span class="ruby-keyword kw">end</span> +175: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">scIdx</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> +176: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">scenarioSpecific?</span>(<span class="ruby-identifier">criteria</span>) +177: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +178: <span class="ruby-node">&quot;Attribute #{criteria} is scenario specific.&quot;</span> <span class="ruby-operator">+</span> +179: <span class="ruby-value str">&quot;You must specify a scenario id.&quot;</span> +180: <span class="ruby-keyword kw">end</span> +181: <span class="ruby-keyword kw">else</span> +182: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">project</span>.<span class="ruby-identifier">scenario</span>(<span class="ruby-identifier">scIdx</span>).<span class="ruby-identifier">nil?</span> +183: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Unknown scenario index #{scIdx} used.&quot;</span> +184: <span class="ruby-keyword kw">end</span> +185: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@propertySet</span>.<span class="ruby-identifier">scenarioSpecific?</span>(<span class="ruby-identifier">criteria</span>) +186: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, <span class="ruby-node">&quot;Attribute #{criteria} is not scenario specific&quot;</span> +187: <span class="ruby-keyword kw">end</span> +188: <span class="ruby-keyword kw">end</span> +189: <span class="ruby-ivar">@sortingCriteria</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">criteria</span>) +190: <span class="ruby-ivar">@sortingUp</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">up</span>) +191: <span class="ruby-ivar">@scenarioIdx</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">scIdx</span>) +192: <span class="ruby-ivar">@sortingLevels</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> +193: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1246,27 +1252,27 @@ <div class="method-source-code" id="index-ree-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 195</span> -195: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">indexTree</span> -196: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">property</span><span class="ruby-operator">|</span> -197: <span class="ruby-comment cmt"># The indicies are an Array if the 'index' attributes for this</span> -198: <span class="ruby-comment cmt"># property and all its parents.</span> -199: <span class="ruby-identifier">treeIdcs</span> = <span class="ruby-identifier">property</span>.<span class="ruby-identifier">getIndicies</span> -200: <span class="ruby-comment cmt"># Now convert them to a String.</span> -201: <span class="ruby-identifier">tree</span> = <span class="ruby-value str">''</span> -202: <span class="ruby-identifier">treeIdcs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">idx</span><span class="ruby-operator">|</span> -203: <span class="ruby-comment cmt"># Prefix the level index with zeros so that we always have a 6</span> -204: <span class="ruby-comment cmt"># digit long String. 6 digits should be large enough for all</span> -205: <span class="ruby-comment cmt"># real-world projects.</span> -206: <span class="ruby-identifier">tree</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">idx</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">rjust</span>(<span class="ruby-value">6</span>, <span class="ruby-value str">'0'</span>) -207: <span class="ruby-keyword kw">end</span> -208: <span class="ruby-identifier">property</span>.<span class="ruby-identifier">set</span>(<span class="ruby-value str">'tree'</span>, <span class="ruby-identifier">tree</span>) -209: <span class="ruby-keyword kw">end</span> -210: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 196</span> +196: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">indexTree</span> +197: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">property</span><span class="ruby-operator">|</span> +198: <span class="ruby-comment cmt"># The indicies are an Array if the 'index' attributes for this</span> +199: <span class="ruby-comment cmt"># property and all its parents.</span> +200: <span class="ruby-identifier">treeIdcs</span> = <span class="ruby-identifier">property</span>.<span class="ruby-identifier">getIndicies</span> +201: <span class="ruby-comment cmt"># Now convert them to a String.</span> +202: <span class="ruby-identifier">tree</span> = <span class="ruby-value str">''</span> +203: <span class="ruby-identifier">treeIdcs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">idx</span><span class="ruby-operator">|</span> +204: <span class="ruby-comment cmt"># Prefix the level index with zeros so that we always have a 6</span> +205: <span class="ruby-comment cmt"># digit long String. 6 digits should be large enough for all</span> +206: <span class="ruby-comment cmt"># real-world projects.</span> +207: <span class="ruby-identifier">tree</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">idx</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">rjust</span>(<span class="ruby-value">6</span>, <span class="ruby-value str">'0'</span>) +208: <span class="ruby-keyword kw">end</span> +209: <span class="ruby-identifier">property</span>.<span class="ruby-identifier">set</span>(<span class="ruby-value str">'tree'</span>, <span class="ruby-identifier">tree</span>) +210: <span class="ruby-keyword kw">end</span> +211: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1293,54 +1299,54 @@ <div class="method-source-code" id="sort-nternal-source"> <pre> - <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 212</span> -212: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sortInternal</span> -213: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">sort!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> -214: <span class="ruby-identifier">res</span> = <span class="ruby-value">0</span> -215: <span class="ruby-ivar">@sortingLevels</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> -216: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@query</span> -217: <span class="ruby-comment cmt"># In case we have a Query reference, we get the two values with this</span> -218: <span class="ruby-comment cmt"># query.</span> -219: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">scenarioIdx</span> = <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>] -220: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>] -221: -222: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">property</span> = <span class="ruby-identifier">a</span> -223: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">process</span> -224: <span class="ruby-identifier">aVal</span> = <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">to_sort</span> -225: -226: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">property</span> = <span class="ruby-identifier">b</span> -227: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">process</span> -228: <span class="ruby-identifier">bVal</span> = <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">to_sort</span> -229: <span class="ruby-keyword kw">else</span> -230: <span class="ruby-comment cmt"># In case we don't have a query, we use the static mechanism.</span> -231: <span class="ruby-comment cmt"># If the scenario index is negative we have a non-scenario-specific</span> -232: <span class="ruby-comment cmt"># attribute.</span> -233: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> -234: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'id'</span> -235: <span class="ruby-identifier">aVal</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">fullId</span> -236: <span class="ruby-identifier">bVal</span> = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">fullId</span> -237: <span class="ruby-keyword kw">else</span> -238: <span class="ruby-identifier">aVal</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>]) -239: <span class="ruby-identifier">bVal</span> = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>]) -240: <span class="ruby-keyword kw">end</span> -241: <span class="ruby-keyword kw">else</span> -242: <span class="ruby-identifier">aVal</span> = <span class="ruby-identifier">a</span>[<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>], <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>]] -243: <span class="ruby-identifier">bVal</span> = <span class="ruby-identifier">b</span>[<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>], <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>]] -244: <span class="ruby-keyword kw">end</span> -245: <span class="ruby-keyword kw">end</span> -246: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">aVal</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">bVal</span> -247: <span class="ruby-comment cmt"># Invert the result if we have to sort in decreasing order.</span> -248: <span class="ruby-identifier">res</span> = <span class="ruby-operator">-</span><span class="ruby-identifier">res</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@sortingUp</span>[<span class="ruby-identifier">i</span>] -249: <span class="ruby-comment cmt"># If the two elements are equal on this compare level we try the next</span> -250: <span class="ruby-comment cmt"># level.</span> -251: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> -252: <span class="ruby-keyword kw">end</span> -253: <span class="ruby-identifier">res</span> -254: <span class="ruby-keyword kw">end</span> -255: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/PropertyList.rb, line 213</span> +213: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sortInternal</span> +214: <span class="ruby-ivar">@items</span>.<span class="ruby-identifier">sort!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span> +215: <span class="ruby-identifier">res</span> = <span class="ruby-value">0</span> +216: <span class="ruby-ivar">@sortingLevels</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> +217: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@query</span> +218: <span class="ruby-comment cmt"># In case we have a Query reference, we get the two values with this</span> +219: <span class="ruby-comment cmt"># query.</span> +220: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">scenarioIdx</span> = <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>] +221: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>] +222: +223: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">property</span> = <span class="ruby-identifier">a</span> +224: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">process</span> +225: <span class="ruby-identifier">aVal</span> = <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">to_sort</span> +226: +227: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">property</span> = <span class="ruby-identifier">b</span> +228: <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">process</span> +229: <span class="ruby-identifier">bVal</span> = <span class="ruby-ivar">@query</span>.<span class="ruby-identifier">to_sort</span> +230: <span class="ruby-keyword kw">else</span> +231: <span class="ruby-comment cmt"># In case we don't have a query, we use the static mechanism.</span> +232: <span class="ruby-comment cmt"># If the scenario index is negative we have a non-scenario-specific</span> +233: <span class="ruby-comment cmt"># attribute.</span> +234: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span> +235: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'id'</span> +236: <span class="ruby-identifier">aVal</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">fullId</span> +237: <span class="ruby-identifier">bVal</span> = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">fullId</span> +238: <span class="ruby-keyword kw">else</span> +239: <span class="ruby-identifier">aVal</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>]) +240: <span class="ruby-identifier">bVal</span> = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>]) +241: <span class="ruby-keyword kw">end</span> +242: <span class="ruby-keyword kw">else</span> +243: <span class="ruby-identifier">aVal</span> = <span class="ruby-identifier">a</span>[<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>], <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>]] +244: <span class="ruby-identifier">bVal</span> = <span class="ruby-identifier">b</span>[<span class="ruby-ivar">@sortingCriteria</span>[<span class="ruby-identifier">i</span>], <span class="ruby-ivar">@scenarioIdx</span>[<span class="ruby-identifier">i</span>]] +245: <span class="ruby-keyword kw">end</span> +246: <span class="ruby-keyword kw">end</span> +247: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">aVal</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">bVal</span> +248: <span class="ruby-comment cmt"># Invert the result if we have to sort in decreasing order.</span> +249: <span class="ruby-identifier">res</span> = <span class="ruby-operator">-</span><span class="ruby-identifier">res</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@sortingUp</span>[<span class="ruby-identifier">i</span>] +250: <span class="ruby-comment cmt"># If the two elements are equal on this compare level we try the next</span> +251: <span class="ruby-comment cmt"># level.</span> +252: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> +253: <span class="ruby-keyword kw">end</span> +254: <span class="ruby-identifier">res</span> +255: <span class="ruby-keyword kw">end</span> +256: <span class="ruby-keyword kw">end</span></pre> </div> </div>