1 <?xml version=
"1.0" encoding=
"iso-8859-1"?>
3 PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
8 <title>more_clockwise (src/clockwise-cloud.rb)
</title>
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1" />
10 <link rel=
"stylesheet" href=
"../../.././rdoc-style.css" type=
"text/css" media=
"screen" />
12 <body class=
"standalone-code">
13 <pre><span class=
"ruby-comment cmt"># File src/clockwise-cloud.rb, line
31</span>
14 <span class=
"ruby-keyword kw">def
</span> <span class=
"ruby-identifier">more_clockwise
</span>(
<span class=
"ruby-identifier">this
</span>,
<span class=
"ruby-identifier">other
</span>)
15 <span class=
"ruby-identifier">here
</span> =
<span class=
"ruby-identifier">this
</span>.
<span class=
"ruby-identifier">place
</span>
16 <span class=
"ruby-identifier">there
</span> =
<span class=
"ruby-identifier">other
</span>.
<span class=
"ruby-identifier">place
</span>
18 <span class=
"ruby-comment cmt"># if both are on a spoke, choose the one with the lowest number (nearer the rim)
</span>
19 <span class=
"ruby-keyword kw">if
</span> <span class=
"ruby-identifier">here
</span> <span class=
"ruby-operator">=~
</span> <span class=
"ruby-regexp re">/.c./
</span> <span class=
"ruby-keyword kw">and
</span> <span class=
"ruby-identifier">there
</span> <span class=
"ruby-operator">=~
</span> <span class=
"ruby-regexp re">/.c./
</span>
20 <span class=
"ruby-comment cmt"># break ties by preferring the most clockwise arc
</span>
21 <span class=
"ruby-keyword kw">if
</span> <span class=
"ruby-identifier">here
</span>[
<span class=
"ruby-value">-
1</span>]
<span class=
"ruby-operator">==
</span> <span class=
"ruby-identifier">there
</span>[
<span class=
"ruby-value">-
1</span>]
22 <span class=
"ruby-keyword kw">return
</span> <span class=
"ruby-identifier">here
</span>[
<span class=
"ruby-value">0</span>]
<span class=
"ruby-operator"><=
></span> <span class=
"ruby-identifier">there
</span>[
<span class=
"ruby-value">0</span>]
23 <span class=
"ruby-keyword kw">else
</span>
24 <span class=
"ruby-keyword kw">return
</span> <span class=
"ruby-value">-
1</span> <span class=
"ruby-operator">*
</span> (
<span class=
"ruby-identifier">here
</span>[
<span class=
"ruby-value">-
1</span>]
<span class=
"ruby-operator"><=
></span> <span class=
"ruby-identifier">there
</span>[
<span class=
"ruby-value">-
1</span>])
25 <span class=
"ruby-keyword kw">end
</span>
26 <span class=
"ruby-comment cmt"># If one is one a spoke and the other is on the rim, choose the one on the rim
</span>
27 <span class=
"ruby-keyword kw">elsif
</span> <span class=
"ruby-identifier">here
</span> <span class=
"ruby-operator">=~
</span> <span class=
"ruby-regexp re">/.c./
</span> <span class=
"ruby-keyword kw">or
</span> <span class=
"ruby-identifier">there
</span> <span class=
"ruby-operator">=~
</span> <span class=
"ruby-regexp re">/.c./
</span>
28 <span class=
"ruby-keyword kw">return
</span> <span class=
"ruby-value">-
1</span> <span class=
"ruby-operator">*
</span> (
<span class=
"ruby-identifier">here
</span>.
<span class=
"ruby-identifier">length
</span> <span class=
"ruby-operator"><=
></span> <span class=
"ruby-identifier">there
</span>.
<span class=
"ruby-identifier">length
</span>)
29 <span class=
"ruby-comment cmt"># If one is in the 'f' rim section and the other in the 'a' rim section, choose the 'a'
</span>
30 <span class=
"ruby-keyword kw">elsif
</span> <span class=
"ruby-identifier">here
</span>[
<span class=
"ruby-value">0</span>,
<span class=
"ruby-value">1</span>]
<span class=
"ruby-operator">==
</span> <span class=
"ruby-value str">'a'
</span> <span class=
"ruby-keyword kw">and
</span> <span class=
"ruby-identifier">there
</span>[
<span class=
"ruby-value">0</span>,
<span class=
"ruby-value">1</span>]
<span class=
"ruby-operator">==
</span> <span class=
"ruby-value str">'f'
</span>
31 <span class=
"ruby-keyword kw">return
</span> <span class=
"ruby-value">+
1</span>
32 <span class=
"ruby-keyword kw">elsif
</span> <span class=
"ruby-identifier">here
</span>[
<span class=
"ruby-value">0</span>,
<span class=
"ruby-value">1</span>]
<span class=
"ruby-operator">==
</span> <span class=
"ruby-value str">'f'
</span> <span class=
"ruby-keyword kw">and
</span> <span class=
"ruby-identifier">there
</span>[
<span class=
"ruby-value">0</span>,
<span class=
"ruby-value">1</span>]
<span class=
"ruby-operator">==
</span> <span class=
"ruby-value str">'a'
</span>
33 <span class=
"ruby-keyword kw">return
</span> <span class=
"ruby-value">-
1</span>
34 <span class=
"ruby-comment cmt"># Otherwise, choose the one with highest arc code
</span>
35 <span class=
"ruby-keyword kw">else
</span>
36 <span class=
"ruby-keyword kw">return
</span> <span class=
"ruby-identifier">here
</span> <span class=
"ruby-operator"><=
></span> <span class=
"ruby-identifier">there
</span>
37 <span class=
"ruby-keyword kw">end
</span>
39 <span class=
"ruby-keyword kw">end
</span></pre>