1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html><head>
<title>Class: Amrita::NodeArray</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 type="text/javascript" language="JavaScript">
<!--
function popCode(url) {
window.open(url, "Code",
"resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
//-->
</script>
</head>
<body bgcolor="white">
<table summary="Information on class" width="100%" border="0" cellspacing="0">
<tr class="title-row">
<td class="big-title-font">
<sup><font color="aqua">Class</font></sup> Amrita::NodeArray
</td>
<td align="right">
<table summary="layout" cellspacing="0" cellpadding="2">
<tr valign="top">
<td class="small-title-font">In:</td>
<td class="small-title-font">
<a href="../../files/lib/amrita/node_expand_rb.html" class="aqua">
lib/amrita/node_expand.rb
</a>
<br />
<a href="../../files/lib/amrita/node_rb.html" class="aqua">
lib/amrita/node.rb
</a>
<br />
<a href="../../files/lib/amrita/format_rb.html" class="aqua">
lib/amrita/format.rb
</a>
<br />
<a href="../../files/lib/amrita/compiler_rb.html" class="aqua">
lib/amrita/compiler.rb
</a>
<br />
</td>
</tr>
<tr>
<td class="small-title-font">Parent:</td>
<td class="small-title-font">
Object
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- banner header -->
<div class="description"><p>
represents an <a href="../Array.html">Array</a> of <a
href="Node.html">Node</a>. It is a <a href="Node.html">Node</a> also.
</p>
</div>
<table summary="Methods" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Methods</td></tr>
</table>
<div class="name-list">
<a href="#M000146">+</a>
<a href="#M000147"><<</a>
<a href="#M000140">==</a>
<a href="#M000142">[]</a>
<a href="#M000138">apply_to_children</a>
<a href="#M000145">children</a>
<a href="#M000144">clone</a>
<a href="#M000151">compile</a>
<a href="#M000149">format</a>
<a href="#M000139">new</a>
<a href="#M000143">no_child?</a>
<a href="#M000150">pre_format1</a>
<a href="#M000141">size</a>
<a href="#M000148">to_ruby</a>
</div>
<table summary="Attributes" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Attributes</td></tr>
</table>
<table summary="Attribute details" cellspacing="5">
<tr valign="top">
<td class="attr-name">:array</td>
<td align="center" class="attr-rw"> [R] </td>
<td></td>
</tr>
</table>
<table summary="Included modules" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Included modules</td></tr>
</table>
<div class="name-list">
<span class="method-name">Node</span>
</div>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Class methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000139"></a>
<b>new</b>(*elements)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 585</span>
<span class="kw">def</span> initialize(*elements)
<span class="kw">if</span> elements.size() == 1 <span class="kw">and</span> elements[0].kind_of?(NodeArray)
a = elements[0]
@array = a.array.collect { |n| n.clone }
<span class="kw">else</span>
@array = elements.collect <span class="kw">do</span> |a|
<span class="cmt">#raise "can't be a parent of me!" if a.id == self.id # no recusive check because it costs too much</span>
to_node(a)
<span class="kw">end</span>
<span class="kw">end</span>
<span class="kw">end</span>
</pre>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Instance methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000138"></a>
<b>apply_to_children</b>(&block) {|n| ...}
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node_expand.rb, line 342</span>
<span class="kw">def</span> apply_to_children(&block)
ret =@array.collect <span class="kw">do</span> |n|
<span class="kw">yield</span>(n)
<span class="kw">end</span>
Node::to_node(ret)
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000140"></a>
<b>==</b>(x)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 597</span>
<span class="kw">def</span> ==(x)
<span class="kw">return</span> <span class="kw">false</span> <span class="kw">unless</span> x.kind_of?(NodeArray)
<span class="kw">case</span> x
<span class="kw">when</span> NodeArray, Array
<span class="kw">return</span> <span class="kw">false</span> <span class="kw">unless</span> x.size() == @array.size()
@array.each_with_index <span class="kw">do</span> |n, i|
<span class="kw">return</span> <span class="kw">false</span> <span class="kw">unless</span> n == x[i]
<span class="kw">end</span>
<span class="kw">true</span>
<span class="kw">else</span>
<span class="kw">false</span>
<span class="kw">end</span>
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000141"></a>
<b>size</b>()
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 611</span>
<span class="kw">def</span> size()
@array.size()
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000142"></a>
<b>[]</b>(index)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 615</span>
<span class="kw">def</span> [](index)
@array[index]
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000143"></a>
<b>no_child?</b>()
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 619</span>
<span class="kw">def</span> no_child?
@array.empty?
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000144"></a>
<b>clone</b>()
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 623</span>
<span class="kw">def</span> clone
NodeArray.new(<span class="kw">self</span>)
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000145"></a>
<b>children</b>()
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 627</span>
<span class="kw">def</span> children
@array
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000146"></a>
<b>+</b>(node)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 631</span>
<span class="kw">def</span> +(node)
ret = clone
ret << node
ret
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000147"></a>
<b><<</b>(node)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 637</span>
<span class="kw">def</span> <<(node)
raise <span class="str">"can't be a parent of me!"</span> <span class="kw">if</span> node == <span class="kw">self</span>
@array << to_node(node)
<span class="kw">self</span>
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000148"></a>
<b>to_ruby</b>()
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/node.rb, line 643</span>
<span class="kw">def</span> to_ruby
<span class="str">"[ "</span> + @array.collect {|e| e.to_ruby}.join(<span class="str">", "</span>) + <span class="str">" ]"</span>
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000149"></a>
<b>format</b>(f)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/format.rb, line 577</span>
<span class="kw">def</span> format(f)
@array.each { |n| n.format(f) }
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000150"></a>
<b>pre_format1</b>(prf)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/format.rb, line 581</span>
<span class="kw">def</span> pre_format1(prf)
@array.each <span class="kw">do</span> |n|
n.pre_format1(prf)
<span class="kw">end</span>
<span class="kw">end</span>
</pre>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000151"></a>
<b>compile</b>(compiler)
</td></tr>
</table>
<pre class="source">
<span class="cmt"># File lib/amrita/compiler.rb, line 105</span>
<span class="kw">def</span> compile(compiler)
children.each { |node| node.compile(compiler) }
<span class="kw">end</span>
</pre>
</body>
|