sdl4r 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -1
- data/README +4 -4
- data/Rakefile +15 -12
- data/TODO +11 -4
- data/lib/sdl4r/parser.rb +25 -33
- data/lib/sdl4r/parser/token.rb +1 -1
- data/lib/sdl4r/sdl4r.rb +50 -22
- data/lib/sdl4r/sdl_time_span.rb +2 -2
- data/lib/sdl4r/serializer.rb +152 -0
- data/lib/sdl4r/tag.rb +15 -1
- data/test/sdl4r/parser_test.rb +5 -0
- data/test/sdl4r/serializer_test.rb +78 -0
- data/test/sdl4r/tag_test.rb +20 -1
- metadata +52 -81
- data/doc/classes/SDL4R.html +0 -408
- data/doc/classes/SDL4R/Parser.html +0 -190
- data/doc/classes/SDL4R/ParserTest.html +0 -385
- data/doc/classes/SDL4R/SDL4RTest.html +0 -532
- data/doc/classes/SDL4R/SDLTest.html +0 -77
- data/doc/classes/SDL4R/SdlBinary.html +0 -188
- data/doc/classes/SDL4R/SdlParseError.html +0 -110
- data/doc/classes/SDL4R/SdlTimeSpan.html +0 -637
- data/doc/classes/SDL4R/Tag.html +0 -1249
- data/doc/classes/SDL4R/TagTest.html +0 -292
- data/doc/created.rid +0 -1
- data/doc/files/CHANGELOG.html +0 -200
- data/doc/files/LICENSE.html +0 -497
- data/doc/files/README.html +0 -406
- data/doc/files/lib/sdl4r/parser/reader_rb.html +0 -54
- data/doc/files/lib/sdl4r/parser/time_span_with_zone_rb.html +0 -54
- data/doc/files/lib/sdl4r/parser/token_rb.html +0 -54
- data/doc/files/lib/sdl4r/parser/tokenizer_rb.html +0 -54
- data/doc/files/lib/sdl4r/parser_rb.html +0 -62
- data/doc/files/lib/sdl4r/sdl4r_rb.html +0 -64
- data/doc/files/lib/sdl4r/sdl_binary_rb.html +0 -54
- data/doc/files/lib/sdl4r/sdl_parse_error_rb.html +0 -54
- data/doc/files/lib/sdl4r/sdl_time_span_rb.html +0 -54
- data/doc/files/lib/sdl4r/tag_rb.html +0 -64
- data/doc/files/lib/sdl4r_rb.html +0 -54
- data/doc/files/test/sdl4r/parser_test_rb.html +0 -64
- data/doc/files/test/sdl4r/sdl4r_test_rb.html +0 -67
- data/doc/files/test/sdl4r/sdl_test_rb.html +0 -64
- data/doc/files/test/sdl4r/tag_test_rb.html +0 -64
- data/doc/fr_class_index.html +0 -19
- data/doc/fr_file_index.html +0 -37
- data/doc/fr_method_index.html +0 -4711
- data/doc/index.html +0 -15
- data/doc/rdoc-style.css +0 -328
data/doc/classes/SDL4R/Tag.html
DELETED
@@ -1,1249 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
-
<html lang='en'>
|
3
|
-
<head>
|
4
|
-
<title>: SDL4R::Tag [RDoc: Simple Declarative Language for Ruby]</title>
|
5
|
-
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
-
<link href='../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
-
<script type='text/javascript'>
|
8
|
-
//<![CDATA[
|
9
|
-
function popupCode(url) {
|
10
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
-
}
|
12
|
-
|
13
|
-
function toggleCode(id) {
|
14
|
-
var code = document.getElementById(id)
|
15
|
-
|
16
|
-
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
-
return true
|
18
|
-
}
|
19
|
-
|
20
|
-
// Make codeblocks hidden by default
|
21
|
-
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
-
//]]>
|
23
|
-
</script>
|
24
|
-
</head>
|
25
|
-
<body class='page'>
|
26
|
-
<div class='class' id='wrapper'>
|
27
|
-
<div class='header'>
|
28
|
-
<h1 class='name'>
|
29
|
-
<span class='type'>Class</span>
|
30
|
-
SDL4R::Tag
|
31
|
-
</h1>
|
32
|
-
<ol class='paths'>
|
33
|
-
<li>
|
34
|
-
<a href="../../files/lib/sdl4r/tag_rb.html">lib/sdl4r/tag.rb</a>
|
35
|
-
</li>
|
36
|
-
</ol>
|
37
|
-
<div class='parent'>
|
38
|
-
Parent:
|
39
|
-
<strong>Object</strong>
|
40
|
-
</div>
|
41
|
-
</div>
|
42
|
-
<div id='content'>
|
43
|
-
<div id='text'>
|
44
|
-
<div id='description'>
|
45
|
-
<p>
|
46
|
-
SDL documents are made of Tags.
|
47
|
-
</p>
|
48
|
-
<p>
|
49
|
-
See the <a href="../../files/README.html">README</a> for a longer
|
50
|
-
explanation on SDL documents.
|
51
|
-
</p>
|
52
|
-
<p>
|
53
|
-
Do not assume that methods returning sets (Hash, Array, etc) of
|
54
|
-
children/values/attributes/etc in this class returns copies or
|
55
|
-
implementations. It can be one or the other depending on the method. The
|
56
|
-
implementations are designed to be correct and somewhat efficient, not too
|
57
|
-
protect the <a href="Tag.html">Tag</a> internal state from ill-use of the
|
58
|
-
returned values.
|
59
|
-
</p>
|
60
|
-
<h2>Authors</h2>
|
61
|
-
<p>
|
62
|
-
Daniel Leuck, Philippe Vosges
|
63
|
-
</p>
|
64
|
-
</div>
|
65
|
-
<div id='method-list'>
|
66
|
-
<h2>Methods</h2>
|
67
|
-
<h3>public class</h3>
|
68
|
-
<ol>
|
69
|
-
<li><a href="#M000038">new</a></li>
|
70
|
-
</ol>
|
71
|
-
<h3>public instance</h3>
|
72
|
-
<ol>
|
73
|
-
<li><a href="#M000041"><<</a></li>
|
74
|
-
<li><a href="#M000077">==</a></li>
|
75
|
-
<li><a href="#M000040">add_child</a></li>
|
76
|
-
<li><a href="#M000054">add_value</a></li>
|
77
|
-
<li><a href="#M000061">attribute</a></li>
|
78
|
-
<li><a href="#M000063">attributes</a></li>
|
79
|
-
<li><a href="#M000067">attributes=</a></li>
|
80
|
-
<li><a href="#M000049">child</a></li>
|
81
|
-
<li><a href="#M000046">child_count</a></li>
|
82
|
-
<li><a href="#M000047">children</a></li>
|
83
|
-
<li><a href="#M000075">children_to_string</a></li>
|
84
|
-
<li><a href="#M000048">children_values</a></li>
|
85
|
-
<li><a href="#M000065">clear_attributes</a></li>
|
86
|
-
<li><a href="#M000043">clear_children</a></li>
|
87
|
-
<li><a href="#M000057">clear_values</a></li>
|
88
|
-
<li><a href="#M000076">eql?</a></li>
|
89
|
-
<li><a href="#M000062">has_attribute?</a></li>
|
90
|
-
<li><a href="#M000050">has_child?</a></li>
|
91
|
-
<li><a href="#M000051">has_children?</a></li>
|
92
|
-
<li><a href="#M000055">has_value?</a></li>
|
93
|
-
<li><a href="#M000078">hash</a></li>
|
94
|
-
<li><a href="#M000068">name=</a></li>
|
95
|
-
<li><a href="#M000069">namespace=</a></li>
|
96
|
-
<li><a href="#M000039">new_child</a></li>
|
97
|
-
<li><a href="#M000070">read</a></li>
|
98
|
-
<li><a href="#M000071">read_from_io</a></li>
|
99
|
-
<li><a href="#M000064">remove_attribute</a></li>
|
100
|
-
<li><a href="#M000042">remove_child</a></li>
|
101
|
-
<li><a href="#M000056">remove_value</a></li>
|
102
|
-
<li><a href="#M000060">set_attribute</a></li>
|
103
|
-
<li><a href="#M000066">set_attributes</a></li>
|
104
|
-
<li><a href="#M000052">to_child_hash</a></li>
|
105
|
-
<li><a href="#M000053">to_child_string_hash</a></li>
|
106
|
-
<li><a href="#M000073">to_s</a></li>
|
107
|
-
<li><a href="#M000074">to_string</a></li>
|
108
|
-
<li><a href="#M000079">to_xml_string</a></li>
|
109
|
-
<li><a href="#M000045">value</a></li>
|
110
|
-
<li><a href="#M000044">value=</a></li>
|
111
|
-
<li><a href="#M000058">values</a></li>
|
112
|
-
<li><a href="#M000059">values=</a></li>
|
113
|
-
<li><a href="#M000072">write</a></li>
|
114
|
-
</ol>
|
115
|
-
<h3>protected instance</h3>
|
116
|
-
<ol>
|
117
|
-
<li><a href="#M000080">_to_xml_string</a></li>
|
118
|
-
</ol>
|
119
|
-
</div>
|
120
|
-
<div id='section'>
|
121
|
-
<div id='attribute-list'>
|
122
|
-
<h2 class='section-bar'>Attributes</h2>
|
123
|
-
<div class='name-list'>
|
124
|
-
<table>
|
125
|
-
<tr class='top-aligned-row context-row'>
|
126
|
-
<td class='context-item-name'>name</td>
|
127
|
-
<td class='context-item-value'>[R]</td>
|
128
|
-
<td class='context-item-desc'>
|
129
|
-
|
130
|
-
the name of this <a href="Tag.html">Tag</a>
|
131
|
-
</td>
|
132
|
-
</tr>
|
133
|
-
<tr class='top-aligned-row context-row'>
|
134
|
-
<td class='context-item-name'>namespace</td>
|
135
|
-
<td class='context-item-value'>[R]</td>
|
136
|
-
<td class='context-item-desc'>
|
137
|
-
|
138
|
-
the namespace of this <a href="Tag.html">Tag</a> or an empty string when
|
139
|
-
there is no namespace (i.e. default namespace).
|
140
|
-
</td>
|
141
|
-
</tr>
|
142
|
-
</table>
|
143
|
-
</div>
|
144
|
-
</div>
|
145
|
-
<div id='methods'>
|
146
|
-
<h2>Public class methods</h2>
|
147
|
-
<div class='method public-class' id='method-M000038'>
|
148
|
-
<a name='M000038'></a>
|
149
|
-
<div class='synopsis'>
|
150
|
-
<span class='name'>new</span>
|
151
|
-
<span class='arguments'>(namespace, name = nil, &block)</span>
|
152
|
-
</div>
|
153
|
-
<div class='description'>
|
154
|
-
<p>
|
155
|
-
Creates an empty tag in the given namespace. If the <tt>namespace</tt> is
|
156
|
-
nil it will be coerced to an empty String.
|
157
|
-
</p>
|
158
|
-
<pre>tag = Tag.new("name")
tag = Tag.new("namespace", "name")

tag = Tag.new("fruit") do
 add_value 2
 new_child("orange") do
 set_attribute("quantity", 2)
 end
end</pre>
|
159
|
-
<p>
|
160
|
-
which builds the following SDL structure
|
161
|
-
</p>
|
162
|
-
<pre>fruit 2 {
 orange quantity=2
}</pre>
|
163
|
-
<p>
|
164
|
-
If you provide a block that takes an argument, you will write the same
|
165
|
-
example, as follows:
|
166
|
-
</p>
|
167
|
-
<pre>tag = Tag.new("fruit") do |t|
 t.add_value 2
 t.new_child("orange") do
 set_attribute("quantity", 2)
 end
end</pre>
|
168
|
-
<p>
|
169
|
-
In this case, the current context is not the new <a href="Tag.html">Tag</a>
|
170
|
-
anymore but the context of your code.
|
171
|
-
</p>
|
172
|
-
<h3>Raises</h3>
|
173
|
-
<p>
|
174
|
-
ArgumentError if the name is not a legal SDL identifier (see <a
|
175
|
-
href="../SDL4R.html#M000005">SDL4R#validate_identifier</a>) or the
|
176
|
-
namespace is non-blank and is not a legal SDL identifier.
|
177
|
-
</p>
|
178
|
-
</div>
|
179
|
-
<div class='source'>
|
180
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000038-source'); return false">
|
181
|
-
[show source]
|
182
|
-
</a>
|
183
|
-
<pre id='M000038-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 106</span>
106: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
107: <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span> = <span class="ruby-identifier">to_nns</span> <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span>
108: 
109: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"tag namespace must be a String"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
110: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"tag name must be a String"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
111: 
112: <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">namespace</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span>
113: <span class="ruby-ivar">@namespace</span> = <span class="ruby-identifier">namespace</span>
114: 
115: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>
116: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Tag name cannot be nil or empty"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">empty?</span>
117: <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">name</span>)
118: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
119: 
120: <span class="ruby-ivar">@children</span> = []
121: <span class="ruby-ivar">@values</span> = []
122: 
123: <span class="ruby-comment cmt"># a Hash of Hash : {namespace => {name => value}}</span>
124: <span class="ruby-comment cmt"># The default namespace is represented by an empty string.</span>
125: <span class="ruby-ivar">@attributesByNamespace</span> = {}
126: 
127: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
128: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
129: <span class="ruby-identifier">block</span>[<span class="ruby-keyword kw">self</span>]
130: <span class="ruby-keyword kw">else</span>
131: <span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
132: <span class="ruby-keyword kw">end</span>
133: <span class="ruby-keyword kw">end</span>
134: <span class="ruby-keyword kw">end</span></pre>
|
184
|
-
</div>
|
185
|
-
</div>
|
186
|
-
<h2>Public instance methods</h2>
|
187
|
-
<div class='method public-instance' id='method-M000041'>
|
188
|
-
<a name='M000041'></a>
|
189
|
-
<div class='synopsis'>
|
190
|
-
<span class='name'><<</span>
|
191
|
-
<span class='arguments'>(o)</span>
|
192
|
-
</div>
|
193
|
-
<div class='description'>
|
194
|
-
<p>
|
195
|
-
Adds the given object as a child if it is a <tt>Tag</tt>, as an attribute
|
196
|
-
if it is a Hash {key => value} (supports namespaces), or as a value
|
197
|
-
otherwise. If it is an Enumerable (e.g. Array), each of its elements is
|
198
|
-
added to this <a href="Tag.html">Tag</a> via this operator. If any of its
|
199
|
-
elements is itself an Enumerable, then an anonymous tag is created and the
|
200
|
-
Enumerable is passed to it via this operator (see the examples below).
|
201
|
-
</p>
|
202
|
-
<pre>tag << Tag.new("child")
tag << 123 # new integer value
tag << "islamabad" # new string value
tag << { "metric:length" => 1027 } # new attribute (with namespace)
tag << [nil, 456, "abc"] # several values added

tag = Tag.new("tag")
tag << [[1, 2, 3], [4, 5, 6]] # tag {
 # 1 2 3
 # 4 5 6
 # }</pre>
|
203
|
-
<p>
|
204
|
-
Of course, despite the fact that String is an Enumerable, it is considered
|
205
|
-
as the type of values.
|
206
|
-
</p>
|
207
|
-
<p>
|
208
|
-
Returns <tt>self</tt>.
|
209
|
-
</p>
|
210
|
-
<p>
|
211
|
-
Use other accessors (<a href="Tag.html#M000040">add_child</a>, <a
|
212
|
-
href="Tag.html#M000054">add_value</a>, <a
|
213
|
-
href="Tag.html#M000063">attributes</a>, etc) for a stricter and less
|
214
|
-
“magical” behavior.
|
215
|
-
</p>
|
216
|
-
</div>
|
217
|
-
<div class='source'>
|
218
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000041-source'); return false">
|
219
|
-
[show source]
|
220
|
-
</a>
|
221
|
-
<pre id='M000041-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 198</span>
198: <span class="ruby-keyword kw">def</span> <span class="ruby-operator"><<</span>(<span class="ruby-identifier">o</span>)
199: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Tag</span>)
200: <span class="ruby-identifier">add_child</span>(<span class="ruby-identifier">o</span>)
201: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
202: <span class="ruby-identifier">o</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
203: <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/:/</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/:/</span>)
204: <span class="ruby-identifier">namespace</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">""</span>
205: <span class="ruby-identifier">set_attribute</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
206: }
207: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
208: <span class="ruby-identifier">add_value</span>(<span class="ruby-identifier">o</span>)
209: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Enumerable</span>
210: <span class="ruby-identifier">o</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
211: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Enumerable</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
212: <span class="ruby-identifier">anonymous</span> = <span class="ruby-identifier">new_child</span>(<span class="ruby-constant">ANONYMOUS_TAG_NAME</span>)
213: <span class="ruby-identifier">anonymous</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">item</span>
214: <span class="ruby-keyword kw">else</span>
215: <span class="ruby-keyword kw">self</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">item</span>
216: <span class="ruby-keyword kw">end</span>
217: }
218: <span class="ruby-keyword kw">else</span>
219: <span class="ruby-identifier">add_value</span>(<span class="ruby-identifier">o</span>)
220: <span class="ruby-keyword kw">end</span>
221: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
222: <span class="ruby-keyword kw">end</span></pre>
|
222
|
-
</div>
|
223
|
-
</div>
|
224
|
-
<div class='method public-instance' id='method-M000077'>
|
225
|
-
<a name='M000077'></a>
|
226
|
-
<div class='synopsis'>
|
227
|
-
<span class='name'>==</span>
|
228
|
-
<span class='arguments'>(o)</span>
|
229
|
-
</div>
|
230
|
-
<div class='description'>
|
231
|
-
<p>
|
232
|
-
Alias for <a href="Tag.html#M000076">eql?</a>
|
233
|
-
</p>
|
234
|
-
</div>
|
235
|
-
</div>
|
236
|
-
<div class='method public-instance' id='method-M000040'>
|
237
|
-
<a name='M000040'></a>
|
238
|
-
<div class='synopsis'>
|
239
|
-
<span class='name'>add_child</span>
|
240
|
-
<span class='arguments'>(child)</span>
|
241
|
-
</div>
|
242
|
-
<div class='description'>
|
243
|
-
<p>
|
244
|
-
Add a child to this <a href="Tag.html">Tag</a>.
|
245
|
-
</p>
|
246
|
-
<table>
|
247
|
-
<tr><td valign="top"><em>child</em>:</td><td>The child to add
|
248
|
-
|
249
|
-
</td></tr>
|
250
|
-
</table>
|
251
|
-
<p>
|
252
|
-
Returns the added child.
|
253
|
-
</p>
|
254
|
-
</div>
|
255
|
-
<div class='source'>
|
256
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000040-source'); return false">
|
257
|
-
[show source]
|
258
|
-
</a>
|
259
|
-
<pre id='M000040-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 167</span>
167: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_child</span>(<span class="ruby-identifier">child</span>)
168: <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">child</span>)
169: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">child</span>
170: <span class="ruby-keyword kw">end</span></pre>
|
260
|
-
</div>
|
261
|
-
</div>
|
262
|
-
<div class='method public-instance' id='method-M000054'>
|
263
|
-
<a name='M000054'></a>
|
264
|
-
<div class='synopsis'>
|
265
|
-
<span class='name'>add_value</span>
|
266
|
-
<span class='arguments'>(v)</span>
|
267
|
-
</div>
|
268
|
-
<div class='description'>
|
269
|
-
<p>
|
270
|
-
Adds a value to this <a href="Tag.html">Tag</a>. See <a
|
271
|
-
href="../SDL4R.html#M000004">SDL4R#coerce_or_fail</a> to know about the
|
272
|
-
allowable types.
|
273
|
-
</p>
|
274
|
-
<table>
|
275
|
-
<tr><td valign="top"><em>v</em>:</td><td>The value to add
|
276
|
-
|
277
|
-
</td></tr>
|
278
|
-
</table>
|
279
|
-
<p>
|
280
|
-
Raises an <tt>ArgumentError</tt> if the value is not a legal SDL type
|
281
|
-
</p>
|
282
|
-
</div>
|
283
|
-
<div class='source'>
|
284
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000054-source'); return false">
|
285
|
-
[show source]
|
286
|
-
</a>
|
287
|
-
<pre id='M000054-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 440</span>
440: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_value</span>(<span class="ruby-identifier">v</span>)
441: <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">SDL4R</span><span class="ruby-operator">::</span><span class="ruby-identifier">coerce_or_fail</span>(<span class="ruby-identifier">v</span>))
442: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
443: <span class="ruby-keyword kw">end</span></pre>
|
288
|
-
</div>
|
289
|
-
</div>
|
290
|
-
<div class='method public-instance' id='method-M000061'>
|
291
|
-
<a name='M000061'></a>
|
292
|
-
<div class='synopsis'>
|
293
|
-
<span class='name'>attribute</span>
|
294
|
-
<span class='arguments'>(namespace, key = nil)</span>
|
295
|
-
</div>
|
296
|
-
<div class='description'>
|
297
|
-
<pre>attribute(key)
attribute(namespace, key)</pre>
|
298
|
-
<p>
|
299
|
-
Returns the attribute of the specified <tt>namespace</tt> of specified
|
300
|
-
<tt>key</tt> or <tt>nil</tt> if not found.
|
301
|
-
</p>
|
302
|
-
</div>
|
303
|
-
<div class='source'>
|
304
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000061-source'); return false">
|
305
|
-
[show source]
|
306
|
-
</a>
|
307
|
-
<pre id='M000061-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 546</span>
546: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">attribute</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">nil</span>)
547: <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span> = <span class="ruby-identifier">to_nns</span> <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>
548: <span class="ruby-identifier">attributes</span> = <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
549: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">attributes</span>[<span class="ruby-identifier">key</span>]
550: <span class="ruby-keyword kw">end</span></pre>
|
308
|
-
</div>
|
309
|
-
</div>
|
310
|
-
<div class='method public-instance' id='method-M000063'>
|
311
|
-
<a name='M000063'></a>
|
312
|
-
<div class='synopsis'>
|
313
|
-
<span class='name'>attributes</span>
|
314
|
-
<span class='arguments'>(namespace = nil) {|namespace, key, value| ...}</span>
|
315
|
-
</div>
|
316
|
-
<div class='description'>
|
317
|
-
<p>
|
318
|
-
Returns a Hash of the attributes of the specified <tt>namespace</tt>
|
319
|
-
(default is all) or enumerates them.
|
320
|
-
</p>
|
321
|
-
<pre>tag.attributes # => { "length" => 123, "width" = 25.4, "orig:color" => "gray" }
tag.attributes("orig") do |namespace, key, value|
 p "#{namespace}:#{key} = #{value}"
end</pre>
|
322
|
-
<p>
|
323
|
-
<em>namespace</em>:: namespace of the returned attributes. If nil, all
|
324
|
-
attributes are returned with qualified names (e.g.
|
325
|
-
“meat:color”). If “”, attributes of the default
|
326
|
-
namespace are returned.
|
327
|
-
</p>
|
328
|
-
</div>
|
329
|
-
<div class='source'>
|
330
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000063-source'); return false">
|
331
|
-
[show source]
|
332
|
-
</a>
|
333
|
-
<pre id='M000063-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 584</span>
584: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">attributes</span>(<span class="ruby-identifier">namespace</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) <span class="ruby-comment cmt"># :yields: namespace, key, value</span>
585: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
586: <span class="ruby-identifier">each_attribute</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
587: 
588: <span class="ruby-keyword kw">else</span>
589: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">nil?</span>
590: <span class="ruby-identifier">hash</span> = {}
591: 
592: <span class="ruby-identifier">each_attribute</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span> <span class="ruby-operator">|</span>
593: <span class="ruby-identifier">qualified_name</span> = <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-identifier">key</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">namespace</span> <span class="ruby-operator">+</span> <span class="ruby-value str">':'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>
594: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">qualified_name</span>] = <span class="ruby-identifier">value</span>
595: <span class="ruby-keyword kw">end</span>
596: 
597: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">hash</span>
598: 
599: <span class="ruby-keyword kw">else</span>
600: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
601: <span class="ruby-keyword kw">end</span>
602: <span class="ruby-keyword kw">end</span>
603: <span class="ruby-keyword kw">end</span></pre>
|
334
|
-
</div>
|
335
|
-
</div>
|
336
|
-
<div class='method public-instance' id='method-M000067'>
|
337
|
-
<a name='M000067'></a>
|
338
|
-
<div class='synopsis'>
|
339
|
-
<span class='name'>attributes=</span>
|
340
|
-
<span class='arguments'>(attribute_hash)</span>
|
341
|
-
</div>
|
342
|
-
<div class='description'>
|
343
|
-
<p>
|
344
|
-
Sets all the attributes of the default namespace for this <a
|
345
|
-
href="Tag.html">Tag</a> in one operation.
|
346
|
-
</p>
|
347
|
-
<p>
|
348
|
-
See <a href="Tag.html#M000066">set_attributes</a>.
|
349
|
-
</p>
|
350
|
-
</div>
|
351
|
-
<div class='source'>
|
352
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000067-source'); return false">
|
353
|
-
[show source]
|
354
|
-
</a>
|
355
|
-
<pre id='M000067-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 687</span>
687: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">attributes=</span>(<span class="ruby-identifier">attribute_hash</span>)
688: <span class="ruby-identifier">set_attributes</span>(<span class="ruby-identifier">attribute_hash</span>)
689: <span class="ruby-keyword kw">end</span></pre>
|
356
|
-
</div>
|
357
|
-
</div>
|
358
|
-
<div class='method public-instance' id='method-M000049'>
|
359
|
-
<a name='M000049'></a>
|
360
|
-
<div class='synopsis'>
|
361
|
-
<span class='name'>child</span>
|
362
|
-
<span class='arguments'>(recursive = false, name = nil)</span>
|
363
|
-
</div>
|
364
|
-
<div class='description'>
|
365
|
-
<pre>child
child(name)
child(recursive, name)</pre>
|
366
|
-
<p>
|
367
|
-
Get the first child with the given name, optionally using a recursive
|
368
|
-
search.
|
369
|
-
</p>
|
370
|
-
<table>
|
371
|
-
<tr><td valign="top"><em>name</em>:</td><td>the name of the child <a href="Tag.html">Tag</a>. If <tt>nil</tt>, the
|
372
|
-
first child is returned (<tt>nil</tt> if there are
|
373
|
-
|
374
|
-
</td></tr>
|
375
|
-
</table>
|
376
|
-
<p>
|
377
|
-
no children at all).
|
378
|
-
</p>
|
379
|
-
<p>
|
380
|
-
Returns the first child tag having the given name or <tt>nil</tt> if no
|
381
|
-
such child exists
|
382
|
-
</p>
|
383
|
-
</div>
|
384
|
-
<div class='source'>
|
385
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000049-source'); return false">
|
386
|
-
[show source]
|
387
|
-
</a>
|
388
|
-
<pre id='M000049-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 344</span>
344: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">child</span>(<span class="ruby-identifier">recursive</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
345: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">nil?</span>
346: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">recursive</span>
347: <span class="ruby-identifier">recursive</span> = <span class="ruby-keyword kw">false</span>
348: <span class="ruby-keyword kw">end</span>
349: 
350: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">name</span>
351: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">first</span>
352: <span class="ruby-keyword kw">else</span>
353: <span class="ruby-identifier">each_child</span>(<span class="ruby-identifier">recursive</span>, <span class="ruby-identifier">name</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">child</span> }
354: <span class="ruby-keyword kw">end</span>
355: <span class="ruby-keyword kw">end</span></pre>
|
389
|
-
</div>
|
390
|
-
</div>
|
391
|
-
<div class='method public-instance' id='method-M000046'>
|
392
|
-
<a name='M000046'></a>
|
393
|
-
<div class='synopsis'>
|
394
|
-
<span class='name'>child_count</span>
|
395
|
-
<span class='arguments'>()</span>
|
396
|
-
</div>
|
397
|
-
<div class='description'>
|
398
|
-
<p>
|
399
|
-
Returns the number of children <a href="Tag.html">Tag</a>.
|
400
|
-
</p>
|
401
|
-
</div>
|
402
|
-
<div class='source'>
|
403
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000046-source'); return false">
|
404
|
-
[show source]
|
405
|
-
</a>
|
406
|
-
<pre id='M000046-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 265</span>
265: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">child_count</span>
266: <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">size</span>
267: <span class="ruby-keyword kw">end</span></pre>
|
407
|
-
</div>
|
408
|
-
</div>
|
409
|
-
<div class='method public-instance' id='method-M000047'>
|
410
|
-
<a name='M000047'></a>
|
411
|
-
<div class='synopsis'>
|
412
|
-
<span class='name'>children</span>
|
413
|
-
<span class='arguments'>(recursive = false, namespace = nil, name = :DEFAULT) {|child| ...}</span>
|
414
|
-
</div>
|
415
|
-
<div class='description'>
|
416
|
-
<pre>children(recursive)
children(recursive, name)
children(recursive, namespace, name)

children(recursive) { |child| ... }
children(recursive, name) { |child| ... }
children(recursive, namespace, name) { |child| ... }</pre>
|
417
|
-
<p>
|
418
|
-
Returns an Array of the children Tags of this <a href="Tag.html">Tag</a> or
|
419
|
-
enumerates them.
|
420
|
-
</p>
|
421
|
-
<table>
|
422
|
-
<tr><td valign="top"><em>recursive</em>:</td><td>if true children and all descendants will be returned. False by default.
|
423
|
-
|
424
|
-
</td></tr>
|
425
|
-
<tr><td valign="top"><em>name</em>:</td><td>if not nil, only children having this name will be returned. Nil by
|
426
|
-
default.
|
427
|
-
|
428
|
-
</td></tr>
|
429
|
-
<tr><td valign="top"><em>namespace</em>:</td><td>use nil for all namespaces and “” for the default one. Nil by
|
430
|
-
default.
|
431
|
-
|
432
|
-
</td></tr>
|
433
|
-
</table>
|
434
|
-
<pre>tag.children # => array of the children
tag.children(true) { |descendant| ... }

tag.children(false, "name") # => children of name "name"
tag.children(false, "ns", nil) # => children of namespace "ns"</pre>
|
435
|
-
</div>
|
436
|
-
<div class='source'>
|
437
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000047-source'); return false">
|
438
|
-
[show source]
|
439
|
-
</a>
|
440
|
-
<pre id='M000047-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 289</span>
289: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">children</span>(<span class="ruby-identifier">recursive</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">namespace</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">name</span> = <span class="ruby-identifier">:DEFAULT</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) <span class="ruby-comment cmt"># :yields: child</span>
290: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:DEFAULT</span>
291: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">namespace</span>
292: <span class="ruby-identifier">namespace</span> = <span class="ruby-keyword kw">nil</span>
293: <span class="ruby-keyword kw">end</span>
294: 
295: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
296: <span class="ruby-identifier">each_child</span>(<span class="ruby-identifier">recursive</span>, <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
297: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
298: 
299: <span class="ruby-keyword kw">else</span>
300: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">recursive</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">name</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">namespace</span>
301: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@children</span>
302: 
303: <span class="ruby-keyword kw">else</span>
304: <span class="ruby-identifier">result</span> = []
305: <span class="ruby-identifier">each_child</span>(<span class="ruby-identifier">recursive</span>, <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
306: <span class="ruby-identifier">result</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">child</span>
307: }
308: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
309: <span class="ruby-keyword kw">end</span>
310: <span class="ruby-keyword kw">end</span>
311: <span class="ruby-keyword kw">end</span></pre>
|
441
|
-
</div>
|
442
|
-
</div>
|
443
|
-
<div class='method public-instance' id='method-M000075'>
|
444
|
-
<a name='M000075'></a>
|
445
|
-
<div class='synopsis'>
|
446
|
-
<span class='name'>children_to_string</span>
|
447
|
-
<span class='arguments'>(line_prefix = "", s = "")</span>
|
448
|
-
</div>
|
449
|
-
<div class='description'>
|
450
|
-
<p>
|
451
|
-
Returns a string representation of the children tags.
|
452
|
-
</p>
|
453
|
-
<table>
|
454
|
-
<tr><td valign="top"><em>linePrefix</em>:</td><td>A prefix to insert before every line.
|
455
|
-
|
456
|
-
</td></tr>
|
457
|
-
<tr><td valign="top"><em>s</em>:</td><td>a String that receives the string representation
|
458
|
-
|
459
|
-
</td></tr>
|
460
|
-
</table>
|
461
|
-
<p>
|
462
|
-
TODO: break up long lines using the backslash
|
463
|
-
</p>
|
464
|
-
</div>
|
465
|
-
<div class='source'>
|
466
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000075-source'); return false">
|
467
|
-
[show source]
|
468
|
-
</a>
|
469
|
-
<pre id='M000075-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 861</span>
861: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">children_to_string</span>(<span class="ruby-identifier">line_prefix</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">s</span> = <span class="ruby-value str">""</span>)
862: <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
863: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">to_string</span>(<span class="ruby-identifier">line_prefix</span>) <span class="ruby-operator"><<</span> <span class="ruby-identifier">$/</span>
864: <span class="ruby-keyword kw">end</span>
865: 
866: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
867: <span class="ruby-keyword kw">end</span></pre>
|
470
|
-
</div>
|
471
|
-
</div>
|
472
|
-
<div class='method public-instance' id='method-M000048'>
|
473
|
-
<a name='M000048'></a>
|
474
|
-
<div class='synopsis'>
|
475
|
-
<span class='name'>children_values</span>
|
476
|
-
<span class='arguments'>(name = nil)</span>
|
477
|
-
</div>
|
478
|
-
<div class='description'>
|
479
|
-
<p>
|
480
|
-
Returns the values of all the children with the given <tt>name</tt>. If the
|
481
|
-
child has more than one value, all the values will be added as an array. If
|
482
|
-
the child has no value, <tt>nil</tt> will be added. The search is not
|
483
|
-
recursive.
|
484
|
-
</p>
|
485
|
-
<table>
|
486
|
-
<tr><td valign="top"><em>name</em>:</td><td>if nil, all children are considered (nil by default).
|
487
|
-
|
488
|
-
</td></tr>
|
489
|
-
</table>
|
490
|
-
</div>
|
491
|
-
<div class='source'>
|
492
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000048-source'); return false">
|
493
|
-
[show source]
|
494
|
-
</a>
|
495
|
-
<pre id='M000048-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 318</span>
318: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">children_values</span>(<span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
319: <span class="ruby-identifier">children_values</span> = []
320: <span class="ruby-identifier">each_child</span>(<span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">name</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
321: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">size</span>
322: <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span>
323: <span class="ruby-identifier">children_values</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">nil</span>
324: <span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>
325: <span class="ruby-identifier">children_values</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">value</span>
326: <span class="ruby-keyword kw">else</span>
327: <span class="ruby-identifier">children_values</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">values</span>
328: <span class="ruby-keyword kw">end</span>
329: }
330: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">children_values</span>
331: <span class="ruby-keyword kw">end</span></pre>
|
496
|
-
</div>
|
497
|
-
</div>
|
498
|
-
<div class='method public-instance' id='method-M000065'>
|
499
|
-
<a name='M000065'></a>
|
500
|
-
<div class='synopsis'>
|
501
|
-
<span class='name'>clear_attributes</span>
|
502
|
-
<span class='arguments'>(namespace = nil)</span>
|
503
|
-
</div>
|
504
|
-
<div class='description'>
|
505
|
-
<p>
|
506
|
-
Clears the attributes of the specified namespace or all the attributes if
|
507
|
-
<tt>namespace</tt> is <tt>nil</tt>.
|
508
|
-
</p>
|
509
|
-
</div>
|
510
|
-
<div class='source'>
|
511
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000065-source'); return false">
|
512
|
-
[show source]
|
513
|
-
</a>
|
514
|
-
<pre id='M000065-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 624</span>
624: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_attributes</span>(<span class="ruby-identifier">namespace</span> = <span class="ruby-keyword kw">nil</span>)
625: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">nil?</span>
626: <span class="ruby-ivar">@attributesByNamespace</span>.<span class="ruby-identifier">clear</span>
627: <span class="ruby-keyword kw">else</span>
628: <span class="ruby-ivar">@attributesByNamespace</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">namespace</span>)
629: <span class="ruby-keyword kw">end</span>
630: <span class="ruby-keyword kw">end</span></pre>
|
515
|
-
</div>
|
516
|
-
</div>
|
517
|
-
<div class='method public-instance' id='method-M000043'>
|
518
|
-
<a name='M000043'></a>
|
519
|
-
<div class='synopsis'>
|
520
|
-
<span class='name'>clear_children</span>
|
521
|
-
<span class='arguments'>()</span>
|
522
|
-
</div>
|
523
|
-
<div class='description'>
|
524
|
-
<p>
|
525
|
-
Removes all children.
|
526
|
-
</p>
|
527
|
-
</div>
|
528
|
-
<div class='source'>
|
529
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000043-source'); return false">
|
530
|
-
[show source]
|
531
|
-
</a>
|
532
|
-
<pre id='M000043-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 236</span>
236: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_children</span>
237: <span class="ruby-ivar">@children</span> = []
238: <span class="ruby-keyword kw">nil</span>
239: <span class="ruby-keyword kw">end</span></pre>
|
533
|
-
</div>
|
534
|
-
</div>
|
535
|
-
<div class='method public-instance' id='method-M000057'>
|
536
|
-
<a name='M000057'></a>
|
537
|
-
<div class='synopsis'>
|
538
|
-
<span class='name'>clear_values</span>
|
539
|
-
<span class='arguments'>()</span>
|
540
|
-
</div>
|
541
|
-
<div class='description'>
|
542
|
-
<p>
|
543
|
-
Removes all values.
|
544
|
-
</p>
|
545
|
-
</div>
|
546
|
-
<div class='source'>
|
547
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000057-source'); return false">
|
548
|
-
[show source]
|
549
|
-
</a>
|
550
|
-
<pre id='M000057-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 468</span>
468: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_values</span>
469: <span class="ruby-ivar">@values</span> = []
470: <span class="ruby-keyword kw">nil</span>
471: <span class="ruby-keyword kw">end</span></pre>
|
551
|
-
</div>
|
552
|
-
</div>
|
553
|
-
<div class='method public-instance' id='method-M000076'>
|
554
|
-
<a name='M000076'></a>
|
555
|
-
<div class='synopsis'>
|
556
|
-
<span class='name'>eql?</span>
|
557
|
-
<span class='arguments'>(o)</span>
|
558
|
-
</div>
|
559
|
-
<div class='description'>
|
560
|
-
<p>
|
561
|
-
Returns true if this tag (including all of its values, attributes, and
|
562
|
-
children) is equivalent to the given tag.
|
563
|
-
</p>
|
564
|
-
<p>
|
565
|
-
Returns true if the tags are equivalet
|
566
|
-
</p>
|
567
|
-
</div>
|
568
|
-
<div class='source'>
|
569
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000076-source'); return false">
|
570
|
-
[show source]
|
571
|
-
</a>
|
572
|
-
<pre id='M000076-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 874</span>
874: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">eql?</span>(<span class="ruby-identifier">o</span>)
875: <span class="ruby-comment cmt"># this is safe because to_string() dumps the full state</span>
876: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Tag</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_string</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">to_string</span>;
877: <span class="ruby-keyword kw">end</span></pre>
|
573
|
-
</div>
|
574
|
-
</div>
|
575
|
-
<div class='method public-instance' id='method-M000062'>
|
576
|
-
<a name='M000062'></a>
|
577
|
-
<div class='synopsis'>
|
578
|
-
<span class='name'>has_attribute?</span>
|
579
|
-
<span class='arguments'>(namespace = nil, key = nil)</span>
|
580
|
-
</div>
|
581
|
-
<div class='description'>
|
582
|
-
<p>
|
583
|
-
Indicates whether there is at least an attribute in this <a
|
584
|
-
href="Tag.html">Tag</a>.
|
585
|
-
</p>
|
586
|
-
<pre>has_attribute?</pre>
|
587
|
-
<p>
|
588
|
-
Indicates whether there is the specified attribute exists in this <a
|
589
|
-
href="Tag.html">Tag</a>.
|
590
|
-
</p>
|
591
|
-
<pre>has_attribute?(key)
has_attribute?(namespace, key)</pre>
|
592
|
-
</div>
|
593
|
-
<div class='source'>
|
594
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000062-source'); return false">
|
595
|
-
[show source]
|
596
|
-
</a>
|
597
|
-
<pre id='M000062-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 559</span>
559: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_attribute?</span>(<span class="ruby-identifier">namespace</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">nil</span>)
560: <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span> = <span class="ruby-identifier">to_nns</span> <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>
561: 
562: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">key</span>
563: <span class="ruby-identifier">attributes</span> = <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
564: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">false</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>)
565: 
566: <span class="ruby-keyword kw">else</span>
567: <span class="ruby-identifier">attributes</span> { <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> }
568: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
569: <span class="ruby-keyword kw">end</span>
570: <span class="ruby-keyword kw">end</span></pre>
|
598
|
-
</div>
|
599
|
-
</div>
|
600
|
-
<div class='method public-instance' id='method-M000050'>
|
601
|
-
<a name='M000050'></a>
|
602
|
-
<div class='synopsis'>
|
603
|
-
<span class='name'>has_child?</span>
|
604
|
-
<span class='arguments'>(name)</span>
|
605
|
-
</div>
|
606
|
-
<div class='description'>
|
607
|
-
<p>
|
608
|
-
Indicates whether the child <a href="Tag.html">Tag</a> of given name
|
609
|
-
exists.
|
610
|
-
</p>
|
611
|
-
<table>
|
612
|
-
<tr><td valign="top"><em>name</em>:</td><td>name of the searched child <a href="Tag.html">Tag</a>
|
613
|
-
|
614
|
-
</td></tr>
|
615
|
-
</table>
|
616
|
-
</div>
|
617
|
-
<div class='source'>
|
618
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000050-source'); return false">
|
619
|
-
[show source]
|
620
|
-
</a>
|
621
|
-
<pre id='M000050-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 361</span>
361: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_child?</span>(<span class="ruby-identifier">name</span>)
362: <span class="ruby-operator">!</span><span class="ruby-identifier">child</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">nil?</span>
363: <span class="ruby-keyword kw">end</span></pre>
|
622
|
-
</div>
|
623
|
-
</div>
|
624
|
-
<div class='method public-instance' id='method-M000051'>
|
625
|
-
<a name='M000051'></a>
|
626
|
-
<div class='synopsis'>
|
627
|
-
<span class='name'>has_children?</span>
|
628
|
-
<span class='arguments'>()</span>
|
629
|
-
</div>
|
630
|
-
<div class='description'>
|
631
|
-
<p>
|
632
|
-
Indicates whether there are children <a href="Tag.html">Tag</a>.
|
633
|
-
</p>
|
634
|
-
</div>
|
635
|
-
<div class='source'>
|
636
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000051-source'); return false">
|
637
|
-
[show source]
|
638
|
-
</a>
|
639
|
-
<pre id='M000051-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 367</span>
367: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_children?</span>
368: <span class="ruby-operator">!</span><span class="ruby-ivar">@children</span>.<span class="ruby-identifier">empty?</span>
369: <span class="ruby-keyword kw">end</span></pre>
|
640
|
-
</div>
|
641
|
-
</div>
|
642
|
-
<div class='method public-instance' id='method-M000055'>
|
643
|
-
<a name='M000055'></a>
|
644
|
-
<div class='synopsis'>
|
645
|
-
<span class='name'>has_value?</span>
|
646
|
-
<span class='arguments'>(v)</span>
|
647
|
-
</div>
|
648
|
-
<div class='description'>
|
649
|
-
<p>
|
650
|
-
Returns true if <tt>v</tt> is a value of this Tag’s.
|
651
|
-
</p>
|
652
|
-
</div>
|
653
|
-
<div class='source'>
|
654
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000055-source'); return false">
|
655
|
-
[show source]
|
656
|
-
</a>
|
657
|
-
<pre id='M000055-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 447</span>
447: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_value?</span>(<span class="ruby-identifier">v</span>)
448: <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">v</span>)
449: <span class="ruby-keyword kw">end</span></pre>
|
658
|
-
</div>
|
659
|
-
</div>
|
660
|
-
<div class='method public-instance' id='method-M000078'>
|
661
|
-
<a name='M000078'></a>
|
662
|
-
<div class='synopsis'>
|
663
|
-
<span class='name'>hash</span>
|
664
|
-
<span class='arguments'>()</span>
|
665
|
-
</div>
|
666
|
-
<div class='description'>
|
667
|
-
<p>
|
668
|
-
Returns The hash (based on the output from toString())
|
669
|
-
</p>
|
670
|
-
</div>
|
671
|
-
<div class='source'>
|
672
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000078-source'); return false">
|
673
|
-
[show source]
|
674
|
-
</a>
|
675
|
-
<pre id='M000078-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 882</span>
882: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hash</span>
883: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">to_string</span>.<span class="ruby-identifier">hash</span>
884: <span class="ruby-keyword kw">end</span></pre>
|
676
|
-
</div>
|
677
|
-
</div>
|
678
|
-
<div class='method public-instance' id='method-M000068'>
|
679
|
-
<a name='M000068'></a>
|
680
|
-
<div class='synopsis'>
|
681
|
-
<span class='name'>name=</span>
|
682
|
-
<span class='arguments'>(a_name)</span>
|
683
|
-
</div>
|
684
|
-
<div class='description'>
|
685
|
-
<p>
|
686
|
-
Sets the name of this <a href="Tag.html">Tag</a>.
|
687
|
-
</p>
|
688
|
-
<p>
|
689
|
-
Raises <tt>ArgumentError</tt> if the name is not a legal SDL identifier
|
690
|
-
(see <a href="../SDL4R.html#M000005">SDL4R#validate_identifier</a>).
|
691
|
-
</p>
|
692
|
-
</div>
|
693
|
-
<div class='source'>
|
694
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000068-source'); return false">
|
695
|
-
[show source]
|
696
|
-
</a>
|
697
|
-
<pre id='M000068-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 696</span>
696: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">name=</span>(<span class="ruby-identifier">a_name</span>)
697: <span class="ruby-identifier">a_name</span> = <span class="ruby-identifier">a_name</span>.<span class="ruby-identifier">to_s</span>
698: <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">a_name</span>)
699: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">a_name</span>
700: <span class="ruby-keyword kw">end</span></pre>
|
698
|
-
</div>
|
699
|
-
</div>
|
700
|
-
<div class='method public-instance' id='method-M000069'>
|
701
|
-
<a name='M000069'></a>
|
702
|
-
<div class='synopsis'>
|
703
|
-
<span class='name'>namespace=</span>
|
704
|
-
<span class='arguments'>(a_namespace)</span>
|
705
|
-
</div>
|
706
|
-
<div class='description'>
|
707
|
-
<p>
|
708
|
-
The namespace to set. <tt>nil</tt> will be coerced to the empty string.
|
709
|
-
</p>
|
710
|
-
<p>
|
711
|
-
Raises <tt>ArgumentError</tt> if the namespace is non-blank and is not a
|
712
|
-
legal SDL identifier (see <a
|
713
|
-
href="../SDL4R.html#M000005">SDL4R#validate_identifier</a>)
|
714
|
-
</p>
|
715
|
-
</div>
|
716
|
-
<div class='source'>
|
717
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000069-source'); return false">
|
718
|
-
[show source]
|
719
|
-
</a>
|
720
|
-
<pre id='M000069-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 707</span>
707: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">namespace=</span>(<span class="ruby-identifier">a_namespace</span>)
708: <span class="ruby-identifier">a_namespace</span> = <span class="ruby-identifier">a_namespace</span>.<span class="ruby-identifier">to_s</span>
709: <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">a_namespace</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">a_namespace</span>.<span class="ruby-identifier">empty?</span>
710: <span class="ruby-ivar">@namespace</span> = <span class="ruby-identifier">a_namespace</span>
711: <span class="ruby-keyword kw">end</span></pre>
|
721
|
-
</div>
|
722
|
-
</div>
|
723
|
-
<div class='method public-instance' id='method-M000039'>
|
724
|
-
<a name='M000039'></a>
|
725
|
-
<div class='synopsis'>
|
726
|
-
<span class='name'>new_child</span>
|
727
|
-
<span class='arguments'>(*args, &block)</span>
|
728
|
-
</div>
|
729
|
-
<div class='description'>
|
730
|
-
<p>
|
731
|
-
Creates a new child tag. Can take a block so that you can write something
|
732
|
-
like:
|
733
|
-
</p>
|
734
|
-
<pre>car = Tag.new("car") do
 new_child("wheels") do
 self << 4
 end
end</pre>
|
735
|
-
<p>
|
736
|
-
The context of execution of the given block is the child instance. If you
|
737
|
-
provide a block that takes a parameter (see below), the context is the
|
738
|
-
context of your code:
|
739
|
-
</p>
|
740
|
-
<pre>car = Tag.new("car") do |child|
 child.new_child("wheels") do |grandchild|
 grandchild << 4
 end
end</pre>
|
741
|
-
<p>
|
742
|
-
Returns the created child <a href="Tag.html">Tag</a>.
|
743
|
-
</p>
|
744
|
-
</div>
|
745
|
-
<div class='source'>
|
746
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000039-source'); return false">
|
747
|
-
[show source]
|
748
|
-
</a>
|
749
|
-
<pre id='M000039-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 157</span>
157: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new_child</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
158: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">add_child</span> <span class="ruby-constant">Tag</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
159: <span class="ruby-keyword kw">end</span></pre>
|
750
|
-
</div>
|
751
|
-
</div>
|
752
|
-
<div class='method public-instance' id='method-M000070'>
|
753
|
-
<a name='M000070'></a>
|
754
|
-
<div class='synopsis'>
|
755
|
-
<span class='name'>read</span>
|
756
|
-
<span class='arguments'>(input)</span>
|
757
|
-
</div>
|
758
|
-
<div class='description'>
|
759
|
-
<p>
|
760
|
-
Adds all the tags specified in the given IO, String, Pathname or URI to
|
761
|
-
this <a href="Tag.html">Tag</a>.
|
762
|
-
</p>
|
763
|
-
<p>
|
764
|
-
Returns this <a href="Tag.html">Tag</a> after adding all the children read
|
765
|
-
from <tt>input</tt>.
|
766
|
-
</p>
|
767
|
-
</div>
|
768
|
-
<div class='source'>
|
769
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000070-source'); return false">
|
770
|
-
[show source]
|
771
|
-
</a>
|
772
|
-
<pre id='M000070-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 717</span>
717: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span>(<span class="ruby-identifier">input</span>)
718: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
719: <span class="ruby-identifier">read_from_io</span>(<span class="ruby-keyword kw">true</span>) { <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">input</span>) }
720: 
721: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Pathname</span>
722: <span class="ruby-identifier">read_from_io</span>(<span class="ruby-keyword kw">true</span>) { <span class="ruby-identifier">input</span>.<span class="ruby-identifier">open</span>(<span class="ruby-value str">"r:UTF-8"</span>) }
723: 
724: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">input</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">URI</span>
725: <span class="ruby-identifier">read_from_io</span>(<span class="ruby-keyword kw">true</span>) { <span class="ruby-identifier">input</span>.<span class="ruby-identifier">open</span> }
726: 
727: <span class="ruby-keyword kw">else</span>
728: <span class="ruby-identifier">read_from_io</span>(<span class="ruby-keyword kw">false</span>) { <span class="ruby-identifier">input</span> }
729: <span class="ruby-keyword kw">end</span>
730: 
731: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
732: <span class="ruby-keyword kw">end</span></pre>
|
773
|
-
</div>
|
774
|
-
</div>
|
775
|
-
<div class='method public-instance' id='method-M000071'>
|
776
|
-
<a name='M000071'></a>
|
777
|
-
<div class='synopsis'>
|
778
|
-
<span class='name'>read_from_io</span>
|
779
|
-
<span class='arguments'>(close_io) {|| ...}</span>
|
780
|
-
</div>
|
781
|
-
<div class='description'>
|
782
|
-
<p>
|
783
|
-
Reads and parses the <tt>io</tt> returned by the specified block and closes
|
784
|
-
this <tt>io</tt> if <tt>close_io</tt> is true.
|
785
|
-
</p>
|
786
|
-
</div>
|
787
|
-
<div class='source'>
|
788
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000071-source'); return false">
|
789
|
-
[show source]
|
790
|
-
</a>
|
791
|
-
<pre id='M000071-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 736</span>
736: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_from_io</span>(<span class="ruby-identifier">close_io</span>)
737: <span class="ruby-identifier">io</span> = <span class="ruby-keyword kw">yield</span>
738: 
739: <span class="ruby-keyword kw">begin</span>
740: <span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">io</span>).<span class="ruby-identifier">parse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tag</span><span class="ruby-operator">|</span>
741: <span class="ruby-identifier">add_child</span>(<span class="ruby-identifier">tag</span>)
742: <span class="ruby-keyword kw">end</span>
743: 
744: <span class="ruby-keyword kw">ensure</span>
745: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">close_io</span>
746: <span class="ruby-identifier">io</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">IOError</span>
747: <span class="ruby-keyword kw">end</span>
748: <span class="ruby-keyword kw">end</span>
749: <span class="ruby-keyword kw">end</span></pre>
|
792
|
-
</div>
|
793
|
-
</div>
|
794
|
-
<div class='method public-instance' id='method-M000064'>
|
795
|
-
<a name='M000064'></a>
|
796
|
-
<div class='synopsis'>
|
797
|
-
<span class='name'>remove_attribute</span>
|
798
|
-
<span class='arguments'>(namespace, key = nil)</span>
|
799
|
-
</div>
|
800
|
-
<div class='description'>
|
801
|
-
<pre>remove_attribute(key)
remove_attribute(namespace, key)</pre>
|
802
|
-
<p>
|
803
|
-
Removes the attribute, whose name and namespace are specified.
|
804
|
-
</p>
|
805
|
-
<table>
|
806
|
-
<tr><td valign="top"><em>key</em>:</td><td>name of the removed atribute
|
807
|
-
|
808
|
-
</td></tr>
|
809
|
-
<tr><td valign="top"><em>namespace</em>:</td><td>namespace of the removed attribute (equal to “”, default
|
810
|
-
namespace, by default)
|
811
|
-
|
812
|
-
</td></tr>
|
813
|
-
</table>
|
814
|
-
<p>
|
815
|
-
Returns the value of the removed attribute or <tt>nil</tt> if it
|
816
|
-
didn’t exist.
|
817
|
-
</p>
|
818
|
-
</div>
|
819
|
-
<div class='source'>
|
820
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000064-source'); return false">
|
821
|
-
[show source]
|
822
|
-
</a>
|
823
|
-
<pre id='M000064-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 615</span>
615: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_attribute</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">nil</span>)
616: <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span> = <span class="ruby-identifier">to_nns</span> <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>
617: <span class="ruby-identifier">attributes</span> = <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
618: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
619: <span class="ruby-keyword kw">end</span></pre>
|
824
|
-
</div>
|
825
|
-
</div>
|
826
|
-
<div class='method public-instance' id='method-M000042'>
|
827
|
-
<a name='M000042'></a>
|
828
|
-
<div class='synopsis'>
|
829
|
-
<span class='name'>remove_child</span>
|
830
|
-
<span class='arguments'>(child)</span>
|
831
|
-
</div>
|
832
|
-
<div class='description'>
|
833
|
-
<p>
|
834
|
-
Remove a child from this <a href="Tag.html">Tag</a>
|
835
|
-
</p>
|
836
|
-
<table>
|
837
|
-
<tr><td valign="top"><em>child</em>:</td><td>the child to remove
|
838
|
-
|
839
|
-
</td></tr>
|
840
|
-
</table>
|
841
|
-
<p>
|
842
|
-
Returns true if the child exists and is removed
|
843
|
-
</p>
|
844
|
-
</div>
|
845
|
-
<div class='source'>
|
846
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000042-source'); return false">
|
847
|
-
[show source]
|
848
|
-
</a>
|
849
|
-
<pre id='M000042-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 230</span>
230: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_child</span>(<span class="ruby-identifier">child</span>)
231: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@children</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">child</span>).<span class="ruby-identifier">nil?</span>
232: <span class="ruby-keyword kw">end</span></pre>
|
850
|
-
</div>
|
851
|
-
</div>
|
852
|
-
<div class='method public-instance' id='method-M000056'>
|
853
|
-
<a name='M000056'></a>
|
854
|
-
<div class='synopsis'>
|
855
|
-
<span class='name'>remove_value</span>
|
856
|
-
<span class='arguments'>(v)</span>
|
857
|
-
</div>
|
858
|
-
<div class='description'>
|
859
|
-
<p>
|
860
|
-
Removes the first occurence of the specified value from this <a
|
861
|
-
href="Tag.html">Tag</a>.
|
862
|
-
</p>
|
863
|
-
<table>
|
864
|
-
<tr><td valign="top"><em>v</em>:</td><td>The value to remove
|
865
|
-
|
866
|
-
</td></tr>
|
867
|
-
</table>
|
868
|
-
<p>
|
869
|
-
Returns true If the value exists and is removed
|
870
|
-
</p>
|
871
|
-
</div>
|
872
|
-
<div class='source'>
|
873
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000056-source'); return false">
|
874
|
-
[show source]
|
875
|
-
</a>
|
876
|
-
<pre id='M000056-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 457</span>
457: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_value</span>(<span class="ruby-identifier">v</span>)
458: <span class="ruby-identifier">index</span> = <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">v</span>)
459: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">index</span>
460: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@values</span>.<span class="ruby-identifier">delete_at</span>(<span class="ruby-identifier">index</span>).<span class="ruby-identifier">nil?</span>
461: <span class="ruby-keyword kw">else</span>
462: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
463: <span class="ruby-keyword kw">end</span>
464: <span class="ruby-keyword kw">end</span></pre>
|
877
|
-
</div>
|
878
|
-
</div>
|
879
|
-
<div class='method public-instance' id='method-M000060'>
|
880
|
-
<a name='M000060'></a>
|
881
|
-
<div class='synopsis'>
|
882
|
-
<span class='name'>set_attribute</span>
|
883
|
-
<span class='arguments'>(namespace, key, value = :default)</span>
|
884
|
-
</div>
|
885
|
-
<div class='description'>
|
886
|
-
<pre>set_attribute(key, value)
set_attribute(namespace, key, value)</pre>
|
887
|
-
<p>
|
888
|
-
Set an attribute in the given namespace for this tag. The allowable
|
889
|
-
attribute value types are the same as those allowed for <a
|
890
|
-
href="Tag.html#M000054">add_value</a>.
|
891
|
-
</p>
|
892
|
-
<table>
|
893
|
-
<tr><td valign="top"><em>namespace</em>:</td><td>The namespace for this attribute
|
894
|
-
|
895
|
-
</td></tr>
|
896
|
-
<tr><td valign="top"><em>key</em>:</td><td>The attribute key
|
897
|
-
|
898
|
-
</td></tr>
|
899
|
-
<tr><td valign="top"><em>value</em>:</td><td>The attribute value
|
900
|
-
|
901
|
-
</td></tr>
|
902
|
-
</table>
|
903
|
-
<p>
|
904
|
-
Raises <tt>ArgumentError</tt> if the key is not a legal SDL identifier (see
|
905
|
-
<a href="../SDL4R.html#M000005">SDL4R#validate_identifier</a>), or the
|
906
|
-
namespace is non-blank and is not a legal SDL identifier, or thevalue is
|
907
|
-
not a legal SDL type
|
908
|
-
</p>
|
909
|
-
</div>
|
910
|
-
<div class='source'>
|
911
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000060-source'); return false">
|
912
|
-
[show source]
|
913
|
-
</a>
|
914
|
-
<pre id='M000060-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 516</span>
516: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_attribute</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span> = <span class="ruby-identifier">:default</span>)
517: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:default</span>
518: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">key</span>
519: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">namespace</span>
520: <span class="ruby-identifier">namespace</span> = <span class="ruby-value str">""</span>
521: <span class="ruby-keyword kw">end</span>
522: 
523: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"attribute namespace must be a String"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
524: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"attribute key must be a String"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
525: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"attribute key cannot be empty"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">empty?</span>
526: 
527: <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">namespace</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span>
528: <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">key</span>)
529: 
530: <span class="ruby-identifier">attributes</span> = <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
531: 
532: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">nil?</span>
533: <span class="ruby-identifier">attributes</span> = {}
534: <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>] = <span class="ruby-identifier">attributes</span>
535: <span class="ruby-keyword kw">end</span>
536: 
537: <span class="ruby-identifier">attributes</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">coerce_or_fail</span>(<span class="ruby-identifier">value</span>)
538: <span class="ruby-keyword kw">end</span></pre>
|
915
|
-
</div>
|
916
|
-
</div>
|
917
|
-
<div class='method public-instance' id='method-M000066'>
|
918
|
-
<a name='M000066'></a>
|
919
|
-
<div class='synopsis'>
|
920
|
-
<span class='name'>set_attributes</span>
|
921
|
-
<span class='arguments'>(namespace, attribute_hash = nil)</span>
|
922
|
-
</div>
|
923
|
-
<div class='description'>
|
924
|
-
<pre>set_attributes(attribute_hash)
set_attributes(namespace, attribute_hash)</pre>
|
925
|
-
<p>
|
926
|
-
Sets the attributes specified by a Hash in the given <tt>namespace</tt> in
|
927
|
-
one operation. The previous attributes of the specified <tt>namespace</tt>
|
928
|
-
are removed. See <a href="Tag.html#M000060">set_attribute</a> for allowable
|
929
|
-
attribute value types.
|
930
|
-
</p>
|
931
|
-
<table>
|
932
|
-
<tr><td valign="top"><em>attributes</em>:</td><td>a Hash where keys are attribute keys
|
933
|
-
|
934
|
-
</td></tr>
|
935
|
-
<tr><td valign="top"><em>namespace</em>:</td><td>“” (default namespace) by default
|
936
|
-
|
937
|
-
</td></tr>
|
938
|
-
</table>
|
939
|
-
<p>
|
940
|
-
Raises an <tt>ArgumentError</tt> if any key in the map is not a legal SDL
|
941
|
-
identifier (see <a
|
942
|
-
href="../SDL4R.html#M000005">SDL4R#validate_identifier</a>), or any value
|
943
|
-
is not a legal SDL type.
|
944
|
-
</p>
|
945
|
-
</div>
|
946
|
-
<div class='source'>
|
947
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000066-source'); return false">
|
948
|
-
[show source]
|
949
|
-
</a>
|
950
|
-
<pre id='M000066-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 664</span>
664: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_attributes</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">attribute_hash</span> = <span class="ruby-keyword kw">nil</span>)
665: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">attribute_hash</span>.<span class="ruby-identifier">nil?</span>
666: <span class="ruby-identifier">attribute_hash</span> = <span class="ruby-identifier">namespace</span>
667: <span class="ruby-identifier">namespace</span> = <span class="ruby-value str">""</span>
668: <span class="ruby-keyword kw">end</span>
669: 
670: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"namespace can't be nil"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">nil?</span>
671: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"attribute_hash should be a Hash"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">attribute_hash</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
672: 
673: <span class="ruby-identifier">namespace_attributes</span> = <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
674: <span class="ruby-identifier">namespace_attributes</span>.<span class="ruby-identifier">clear</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace_attributes</span>
675: 
676: <span class="ruby-identifier">attribute_hash</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
677: <span class="ruby-comment cmt"># Calling set_attribute() is required to ensure validations</span>
678: <span class="ruby-identifier">set_attribute</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
679: <span class="ruby-keyword kw">end</span>
680: <span class="ruby-keyword kw">end</span></pre>
|
951
|
-
</div>
|
952
|
-
</div>
|
953
|
-
<div class='method public-instance' id='method-M000052'>
|
954
|
-
<a name='M000052'></a>
|
955
|
-
<div class='synopsis'>
|
956
|
-
<span class='name'>to_child_hash</span>
|
957
|
-
<span class='arguments'>()</span>
|
958
|
-
</div>
|
959
|
-
<div class='description'>
|
960
|
-
<p>
|
961
|
-
Returns a new Hash where the children’s names as keys and their
|
962
|
-
values as the key’s value. Example:
|
963
|
-
</p>
|
964
|
-
<pre>child1 "toto"
child2 2</pre>
|
965
|
-
<p>
|
966
|
-
would give
|
967
|
-
</p>
|
968
|
-
<pre>{ "child1" => "toto", "child2" => 2 }</pre>
|
969
|
-
</div>
|
970
|
-
<div class='source'>
|
971
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000052-source'); return false">
|
972
|
-
[show source]
|
973
|
-
</a>
|
974
|
-
<pre id='M000052-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 406</span>
406: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_child_hash</span>
407: <span class="ruby-identifier">hash</span> = {}
408: <span class="ruby-identifier">children</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">child</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">child</span>.<span class="ruby-identifier">value</span> }
409: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">hash</span>
410: <span class="ruby-keyword kw">end</span></pre>
|
975
|
-
</div>
|
976
|
-
</div>
|
977
|
-
<div class='method public-instance' id='method-M000053'>
|
978
|
-
<a name='M000053'></a>
|
979
|
-
<div class='synopsis'>
|
980
|
-
<span class='name'>to_child_string_hash</span>
|
981
|
-
<span class='arguments'>()</span>
|
982
|
-
</div>
|
983
|
-
<div class='description'>
|
984
|
-
<p>
|
985
|
-
Returns a new Hash where the children’s names as keys and their
|
986
|
-
values as the key’s value. Values are converted to Strings.
|
987
|
-
<tt>nil</tt> values become empty Strings. Example:
|
988
|
-
</p>
|
989
|
-
<pre>child1 "toto"
child2 2
child3 null</pre>
|
990
|
-
<p>
|
991
|
-
would give
|
992
|
-
</p>
|
993
|
-
<pre>{ "child1" => "toto", "child2" => "2", "child3" => "" }</pre>
|
994
|
-
</div>
|
995
|
-
<div class='source'>
|
996
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000053-source'); return false">
|
997
|
-
[show source]
|
998
|
-
</a>
|
999
|
-
<pre id='M000053-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 424</span>
424: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_child_string_hash</span>
425: <span class="ruby-identifier">hash</span> = {}
426: <span class="ruby-identifier">children</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
427: <span class="ruby-comment cmt"># FIXME: it is quite hard to be sure whether we should mimic the Java version</span>
428: <span class="ruby-comment cmt"># as there might be a lot of values that don't translate nicely to Strings.</span>
429: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">child</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">child</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
430: <span class="ruby-keyword kw">end</span>
431: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">hash</span>
432: <span class="ruby-keyword kw">end</span></pre>
|
1000
|
-
</div>
|
1001
|
-
</div>
|
1002
|
-
<div class='method public-instance' id='method-M000073'>
|
1003
|
-
<a name='M000073'></a>
|
1004
|
-
<div class='synopsis'>
|
1005
|
-
<span class='name'>to_s</span>
|
1006
|
-
<span class='arguments'>()</span>
|
1007
|
-
</div>
|
1008
|
-
<div class='description'>
|
1009
|
-
<p>
|
1010
|
-
Get a String representation of this SDL <a href="Tag.html">Tag</a>. This
|
1011
|
-
method returns a complete description of the Tag’s state using SDL
|
1012
|
-
(i.e. the output can be parsed by <a href="Tag.html#M000070">read</a>)
|
1013
|
-
</p>
|
1014
|
-
<p>
|
1015
|
-
Returns A string representation of this tag using SDL
|
1016
|
-
</p>
|
1017
|
-
</div>
|
1018
|
-
<div class='source'>
|
1019
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000073-source'); return false">
|
1020
|
-
[show source]
|
1021
|
-
</a>
|
1022
|
-
<pre id='M000073-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 795</span>
795: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
796: <span class="ruby-identifier">to_string</span>
797: <span class="ruby-keyword kw">end</span></pre>
|
1023
|
-
</div>
|
1024
|
-
</div>
|
1025
|
-
<div class='method public-instance' id='method-M000074'>
|
1026
|
-
<a name='M000074'></a>
|
1027
|
-
<div class='synopsis'>
|
1028
|
-
<span class='name'>to_string</span>
|
1029
|
-
<span class='arguments'>(line_prefix = "", indent = "\t")</span>
|
1030
|
-
</div>
|
1031
|
-
<div class='description'>
|
1032
|
-
<table>
|
1033
|
-
<tr><td valign="top"><em>linePrefix</em>:</td><td>A prefix to insert before every line.
|
1034
|
-
|
1035
|
-
</td></tr>
|
1036
|
-
</table>
|
1037
|
-
<p>
|
1038
|
-
Returns A string representation of this tag using SDL
|
1039
|
-
</p>
|
1040
|
-
<p>
|
1041
|
-
TODO: break up long lines using the backslash
|
1042
|
-
</p>
|
1043
|
-
</div>
|
1044
|
-
<div class='source'>
|
1045
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000074-source'); return false">
|
1046
|
-
[show source]
|
1047
|
-
</a>
|
1048
|
-
<pre id='M000074-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 804</span>
804: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_string</span>(<span class="ruby-identifier">line_prefix</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">indent</span> = <span class="ruby-value str">"\t"</span>)
805: <span class="ruby-identifier">line_prefix</span> = <span class="ruby-value str">""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line_prefix</span>.<span class="ruby-identifier">nil?</span>
806: <span class="ruby-identifier">s</span> = <span class="ruby-value str">""</span>
807: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">line_prefix</span>
808: 
809: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ANONYMOUS_TAG_NAME</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span>
810: <span class="ruby-identifier">skip_value_space</span> = <span class="ruby-keyword kw">true</span>
811: <span class="ruby-keyword kw">else</span>
812: <span class="ruby-identifier">skip_value_space</span> = <span class="ruby-keyword kw">false</span>
813: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{namespace}:"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span>
814: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">name</span>
815: <span class="ruby-keyword kw">end</span>
816: 
817: <span class="ruby-comment cmt"># output values</span>
818: <span class="ruby-identifier">values</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
819: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">skip_value_space</span>
820: <span class="ruby-identifier">skip_value_space</span> = <span class="ruby-keyword kw">false</span>
821: <span class="ruby-keyword kw">else</span>
822: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" "</span>
823: <span class="ruby-keyword kw">end</span>
824: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">format</span>(<span class="ruby-identifier">value</span>, <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">line_prefix</span>, <span class="ruby-identifier">indent</span>)
825: <span class="ruby-keyword kw">end</span>
826: 
827: <span class="ruby-comment cmt"># output attributes</span>
828: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@attributesByNamespace</span>.<span class="ruby-identifier">empty?</span>
829: <span class="ruby-identifier">all_attributes_hash</span> = <span class="ruby-identifier">attributes</span>
830: <span class="ruby-identifier">all_attributes_array</span> = <span class="ruby-identifier">all_attributes_hash</span>.<span class="ruby-identifier">sort</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
831: <span class="ruby-identifier">namespace1</span>, <span class="ruby-identifier">name1</span> = <span class="ruby-identifier">a</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">':'</span>)
832: <span class="ruby-identifier">namespace1</span>, <span class="ruby-identifier">name1</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">namespace1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name1</span>.<span class="ruby-identifier">nil?</span>
833: <span class="ruby-identifier">namespace2</span>, <span class="ruby-identifier">name2</span> = <span class="ruby-identifier">b</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">':'</span>)
834: <span class="ruby-identifier">namespace2</span>, <span class="ruby-identifier">name2</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">namespace2</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name2</span>.<span class="ruby-identifier">nil?</span>
835: 
836: <span class="ruby-identifier">diff</span> = <span class="ruby-identifier">namespace1</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">namespace2</span>
837: <span class="ruby-identifier">diff</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">name1</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">name2</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">diff</span>
838: }
839: <span class="ruby-identifier">all_attributes_array</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute_name</span>, <span class="ruby-identifier">attribute_value</span><span class="ruby-operator">|</span>
840: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" "</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">attribute_name</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'='</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">format</span>(<span class="ruby-identifier">attribute_value</span>, <span class="ruby-keyword kw">true</span>)
841: <span class="ruby-keyword kw">end</span>
842: <span class="ruby-keyword kw">end</span>
843: 
844: <span class="ruby-comment cmt"># output children</span>
845: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">empty?</span>
846: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" {#{$/}"</span>
847: <span class="ruby-identifier">children_to_string</span>(<span class="ruby-identifier">line_prefix</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">indent</span>, <span class="ruby-identifier">s</span>)
848: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">line_prefix</span> <span class="ruby-operator"><<</span> <span class="ruby-value">?}</span>
849: <span class="ruby-keyword kw">end</span>
850: 
851: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
852: <span class="ruby-keyword kw">end</span></pre>
|
1049
|
-
</div>
|
1050
|
-
</div>
|
1051
|
-
<div class='method public-instance' id='method-M000079'>
|
1052
|
-
<a name='M000079'></a>
|
1053
|
-
<div class='synopsis'>
|
1054
|
-
<span class='name'>to_xml_string</span>
|
1055
|
-
<span class='arguments'>(options = {})</span>
|
1056
|
-
</div>
|
1057
|
-
<div class='description'>
|
1058
|
-
<p>
|
1059
|
-
Returns a string containing an XML representation of this tag. Values will
|
1060
|
-
be represented using _val0, _val1, etc.
|
1061
|
-
</p>
|
1062
|
-
<table>
|
1063
|
-
<tr><td valign="top"><em>options</em>:</td><td>a hash of the options
|
1064
|
-
|
1065
|
-
</td></tr>
|
1066
|
-
</table>
|
1067
|
-
<h3>options:</h3>
|
1068
|
-
<dl>
|
1069
|
-
<dt>:line_prefix</dt><dd>a text prefixing each line (default: “”)
|
1070
|
-
|
1071
|
-
</dd>
|
1072
|
-
<dt>:uri_by_namespace</dt><dd>a Hash giving the URIs for the namespaces
|
1073
|
-
|
1074
|
-
</dd>
|
1075
|
-
<dt>:indent</dt><dd>text specifying one indentation (default: “t“)
|
1076
|
-
|
1077
|
-
</dd>
|
1078
|
-
<dt>:eol</dt><dd>end of line expression (default: “n“)
|
1079
|
-
|
1080
|
-
</dd>
|
1081
|
-
<dt>:omit_null_attributes</dt><dd>if true, null/nil attributes are not exported (default: false). Otherwise,
|
1082
|
-
they are exported as follows:
|
1083
|
-
|
1084
|
-
<pre>tag attr="null"</pre>
|
1085
|
-
</dd>
|
1086
|
-
</dl>
|
1087
|
-
</div>
|
1088
|
-
<div class='source'>
|
1089
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000079-source'); return false">
|
1090
|
-
[show source]
|
1091
|
-
</a>
|
1092
|
-
<pre id='M000079-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 902</span>
902: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_xml_string</span>(<span class="ruby-identifier">options</span> = {})
903: <span class="ruby-identifier">options</span> = {
904: <span class="ruby-identifier">:uri_by_namespace</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">nil</span>,
905: <span class="ruby-identifier">:indent</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"\t"</span>,
906: <span class="ruby-identifier">:line_prefix</span> =<span class="ruby-operator">></span> <span class="ruby-value str">""</span>,
907: <span class="ruby-identifier">:eol</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"\n"</span>,
908: <span class="ruby-identifier">:omit_null_attributes</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">false</span>
909: }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
910: <span class="ruby-identifier">_to_xml_string</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:line_prefix</span>], <span class="ruby-identifier">options</span>)
911: <span class="ruby-keyword kw">end</span></pre>
|
1093
|
-
</div>
|
1094
|
-
</div>
|
1095
|
-
<div class='method public-instance' id='method-M000045'>
|
1096
|
-
<a name='M000045'></a>
|
1097
|
-
<div class='synopsis'>
|
1098
|
-
<span class='name'>value</span>
|
1099
|
-
<span class='arguments'>()</span>
|
1100
|
-
</div>
|
1101
|
-
<div class='description'>
|
1102
|
-
<p>
|
1103
|
-
A convenience method that returns the first value.
|
1104
|
-
</p>
|
1105
|
-
</div>
|
1106
|
-
<div class='source'>
|
1107
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000045-source'); return false">
|
1108
|
-
[show source]
|
1109
|
-
</a>
|
1110
|
-
<pre id='M000045-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 259</span>
259: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">value</span>
260: <span class="ruby-ivar">@values</span>[<span class="ruby-value">0</span>]
261: <span class="ruby-keyword kw">end</span></pre>
|
1111
|
-
</div>
|
1112
|
-
</div>
|
1113
|
-
<div class='method public-instance' id='method-M000044'>
|
1114
|
-
<a name='M000044'></a>
|
1115
|
-
<div class='synopsis'>
|
1116
|
-
<span class='name'>value=</span>
|
1117
|
-
<span class='arguments'>(value)</span>
|
1118
|
-
</div>
|
1119
|
-
<div class='description'>
|
1120
|
-
<p>
|
1121
|
-
A convenience method that sets the first value in the value list. See # <a
|
1122
|
-
href="Tag.html#M000054">add_value</a> for legal types.
|
1123
|
-
</p>
|
1124
|
-
<table>
|
1125
|
-
<tr><td valign="top"><em>value</em>:</td><td>The value to be set.
|
1126
|
-
|
1127
|
-
</td></tr>
|
1128
|
-
</table>
|
1129
|
-
<h3>Raises</h3>
|
1130
|
-
<table>
|
1131
|
-
<tr><td valign="top"><em>ArgumentError</em>:</td><td>if the value is not a legal SDL type
|
1132
|
-
|
1133
|
-
</td></tr>
|
1134
|
-
</table>
|
1135
|
-
</div>
|
1136
|
-
<div class='source'>
|
1137
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000044-source'); return false">
|
1138
|
-
[show source]
|
1139
|
-
</a>
|
1140
|
-
<pre id='M000044-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 251</span>
251: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">value=</span>(<span class="ruby-identifier">value</span>)
252: <span class="ruby-ivar">@values</span>[<span class="ruby-value">0</span>] = <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">coerce_or_fail</span>(<span class="ruby-identifier">value</span>)
253: <span class="ruby-keyword kw">nil</span>
254: <span class="ruby-keyword kw">end</span></pre>
|
1141
|
-
</div>
|
1142
|
-
</div>
|
1143
|
-
<div class='method public-instance' id='method-M000058'>
|
1144
|
-
<a name='M000058'></a>
|
1145
|
-
<div class='synopsis'>
|
1146
|
-
<span class='name'>values</span>
|
1147
|
-
<span class='arguments'>( {|value| ...}</span>
|
1148
|
-
</div>
|
1149
|
-
<div class='description'>
|
1150
|
-
<p>
|
1151
|
-
Returns an Array of the values of this <a href="Tag.html">Tag</a> or
|
1152
|
-
enumerates them.
|
1153
|
-
</p>
|
1154
|
-
<pre>tag.values # => [123, "spices"]
tag.values { |value| puts value }</pre>
|
1155
|
-
</div>
|
1156
|
-
<div class='source'>
|
1157
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000058-source'); return false">
|
1158
|
-
[show source]
|
1159
|
-
</a>
|
1160
|
-
<pre id='M000058-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 478</span>
478: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">values</span> <span class="ruby-comment cmt"># :yields: value</span>
479: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
480: <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">v</span> }
481: <span class="ruby-keyword kw">nil</span>
482: <span class="ruby-keyword kw">else</span>
483: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@values</span>
484: <span class="ruby-keyword kw">end</span>
485: <span class="ruby-keyword kw">end</span></pre>
|
1161
|
-
</div>
|
1162
|
-
</div>
|
1163
|
-
<div class='method public-instance' id='method-M000059'>
|
1164
|
-
<a name='M000059'></a>
|
1165
|
-
<div class='synopsis'>
|
1166
|
-
<span class='name'>values=</span>
|
1167
|
-
<span class='arguments'>(someValues)</span>
|
1168
|
-
</div>
|
1169
|
-
<div class='description'>
|
1170
|
-
<p>
|
1171
|
-
Set the values for this tag. See <a href="Tag.html#M000054">add_value</a>
|
1172
|
-
for legal value types.
|
1173
|
-
</p>
|
1174
|
-
<table>
|
1175
|
-
<tr><td valign="top"><em>values</em>:</td><td>The new values
|
1176
|
-
|
1177
|
-
</td></tr>
|
1178
|
-
</table>
|
1179
|
-
<p>
|
1180
|
-
Raises an <tt>ArgumentError</tt> if the collection contains any values
|
1181
|
-
which are not legal SDL types.
|
1182
|
-
</p>
|
1183
|
-
</div>
|
1184
|
-
<div class='source'>
|
1185
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000059-source'); return false">
|
1186
|
-
[show source]
|
1187
|
-
</a>
|
1188
|
-
<pre id='M000059-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 493</span>
493: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">values=</span>(<span class="ruby-identifier">someValues</span>)
494: <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">clear</span>()
495: <span class="ruby-identifier">someValues</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
496: <span class="ruby-comment cmt"># this is required to ensure validation of types</span>
497: <span class="ruby-identifier">add_value</span>(<span class="ruby-identifier">v</span>)
498: }
499: <span class="ruby-keyword kw">nil</span>
500: <span class="ruby-keyword kw">end</span></pre>
|
1189
|
-
</div>
|
1190
|
-
</div>
|
1191
|
-
<div class='method public-instance' id='method-M000072'>
|
1192
|
-
<a name='M000072'></a>
|
1193
|
-
<div class='synopsis'>
|
1194
|
-
<span class='name'>write</span>
|
1195
|
-
<span class='arguments'>(output, include_root = false)</span>
|
1196
|
-
</div>
|
1197
|
-
<div class='description'>
|
1198
|
-
<p>
|
1199
|
-
Write this tag out to the given IO or StringIO or String (optionally
|
1200
|
-
clipping the root.) Returns <tt>output</tt>.
|
1201
|
-
</p>
|
1202
|
-
<table>
|
1203
|
-
<tr><td valign="top"><em>output</em>:</td><td>an IO or StringIO or a String to write to
|
1204
|
-
|
1205
|
-
</td></tr>
|
1206
|
-
<tr><td valign="top"><tt>include_root</tt>:</td><td>if true this tag will be written out as the root element, if false only the
|
1207
|
-
|
1208
|
-
</td></tr>
|
1209
|
-
</table>
|
1210
|
-
<pre>children will be written. False by default.</pre>
|
1211
|
-
</div>
|
1212
|
-
<div class='source'>
|
1213
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000072-source'); return false">
|
1214
|
-
[show source]
|
1215
|
-
</a>
|
1216
|
-
<pre id='M000072-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 759</span>
759: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">include_root</span> = <span class="ruby-keyword kw">false</span>)
760: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">output</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
761: <span class="ruby-identifier">io</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">output</span>)
762: <span class="ruby-identifier">close_io</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-comment cmt"># indicates we close the IO ourselves</span>
763: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">output</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">IO</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">output</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">StringIO</span>
764: <span class="ruby-identifier">io</span> = <span class="ruby-identifier">output</span>
765: <span class="ruby-identifier">close_io</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># let the caller close the IO</span>
766: <span class="ruby-keyword kw">else</span>
767: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"'output' should be a String or an IO but was #{output.class}"</span>
768: <span class="ruby-keyword kw">end</span>
769: 
770: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">include_root</span>
771: <span class="ruby-identifier">io</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">to_s</span>
772: <span class="ruby-keyword kw">else</span>
773: <span class="ruby-identifier">first</span> = <span class="ruby-keyword kw">true</span>
774: <span class="ruby-identifier">children</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
775: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">first</span>
776: <span class="ruby-identifier">first</span> = <span class="ruby-keyword kw">false</span>
777: <span class="ruby-keyword kw">else</span>
778: <span class="ruby-identifier">io</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">$/</span>
779: <span class="ruby-keyword kw">end</span>
780: <span class="ruby-identifier">io</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">to_s</span>
781: <span class="ruby-keyword kw">end</span>
782: <span class="ruby-keyword kw">end</span>
783: 
784: <span class="ruby-identifier">io</span>.<span class="ruby-identifier">close</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">close_io</span>
785: 
786: <span class="ruby-identifier">output</span>
787: <span class="ruby-keyword kw">end</span></pre>
|
1217
|
-
</div>
|
1218
|
-
</div>
|
1219
|
-
<h2>Protected instance methods</h2>
|
1220
|
-
<div class='method protected-instance' id='method-M000080'>
|
1221
|
-
<a name='M000080'></a>
|
1222
|
-
<div class='synopsis'>
|
1223
|
-
<span class='name'>_to_xml_string</span>
|
1224
|
-
<span class='arguments'>(line_prefix, options)</span>
|
1225
|
-
</div>
|
1226
|
-
<div class='description'>
|
1227
|
-
<p>
|
1228
|
-
Implementation of <a href="Tag.html#M000079">to_xml_string</a> but without
|
1229
|
-
the extra-treatment on parameters for default values.
|
1230
|
-
</p>
|
1231
|
-
</div>
|
1232
|
-
<div class='source'>
|
1233
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000080-source'); return false">
|
1234
|
-
[show source]
|
1235
|
-
</a>
|
1236
|
-
<pre id='M000080-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 917</span>
917: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_to_xml_string</span>(<span class="ruby-identifier">line_prefix</span>, <span class="ruby-identifier">options</span>)
918: <span class="ruby-identifier">eol</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:eol</span>]
919: 
920: <span class="ruby-identifier">s</span> = <span class="ruby-value str">""</span>
921: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">line_prefix</span> <span class="ruby-operator"><<</span> <span class="ruby-value">?<</span>
922: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{namespace}:"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span>
923: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">name</span>
924: 
925: <span class="ruby-comment cmt"># output namespace declarations</span>
926: <span class="ruby-identifier">uri_by_namespace</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:uri_by_namespace</span>]
927: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri_by_namespace</span>
928: <span class="ruby-identifier">uri_by_namespace</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">uri</span><span class="ruby-operator">|</span>
929: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span>
930: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" xmlns:#{namespace}=\"#{uri}\""</span>
931: <span class="ruby-keyword kw">else</span>
932: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" xmlns=\"#{uri}\""</span>
933: <span class="ruby-keyword kw">end</span>
934: <span class="ruby-keyword kw">end</span>
935: <span class="ruby-keyword kw">end</span>
936: 
937: <span class="ruby-comment cmt"># output values</span>
938: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">empty?</span>
939: <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
940: <span class="ruby-ivar">@values</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
941: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" _val"</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"=\""</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">format</span>(<span class="ruby-identifier">value</span>, <span class="ruby-keyword kw">false</span>) <span class="ruby-operator"><<</span> <span class="ruby-value str">"\""</span>
942: <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
943: <span class="ruby-keyword kw">end</span>
944: <span class="ruby-keyword kw">end</span>
945: 
946: <span class="ruby-comment cmt"># output attributes</span>
947: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_attribute?</span>
948: <span class="ruby-identifier">omit_null_attributes</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:omit_null_attributes</span>]
949: <span class="ruby-identifier">attributes</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute_namespace</span>, <span class="ruby-identifier">attribute_name</span>, <span class="ruby-identifier">attribute_value</span><span class="ruby-operator">|</span>
950: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">omit_null_attributes</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">attribute_value</span>.<span class="ruby-identifier">nil?</span>
951: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" "</span>
952: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{attribute_namespace}:"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">attribute_namespace</span>.<span class="ruby-identifier">empty?</span>
953: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">attribute_name</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"=\""</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">format</span>(<span class="ruby-identifier">attribute_value</span>, <span class="ruby-keyword kw">false</span>) <span class="ruby-operator"><<</span> <span class="ruby-value">?"</span>
954: <span class="ruby-keyword kw">end</span>
955: <span class="ruby-keyword kw">end</span>
956: <span class="ruby-keyword kw">end</span>
957: 
958: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">empty?</span>
959: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"/>"</span>
960: <span class="ruby-keyword kw">else</span>
961: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">">"</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">eol</span>
962: <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
963: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">_to_xml_string</span>(<span class="ruby-identifier">line_prefix</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:indent</span>], <span class="ruby-identifier">options</span>) <span class="ruby-operator"><<</span> <span class="ruby-identifier">eol</span>
964: <span class="ruby-keyword kw">end</span>
965: 
966: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">line_prefix</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"</"</span>
967: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{namespace}:"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">empty?</span>
968: <span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">name</span> <span class="ruby-operator"><<</span> <span class="ruby-value">?></span>
969: <span class="ruby-keyword kw">end</span>
970: 
971: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
972: <span class="ruby-keyword kw">end</span></pre>
|
1237
|
-
</div>
|
1238
|
-
</div>
|
1239
|
-
</div>
|
1240
|
-
</div>
|
1241
|
-
</div>
|
1242
|
-
</div>
|
1243
|
-
<div id='footer-push'></div>
|
1244
|
-
</div>
|
1245
|
-
<div id='footer'>
|
1246
|
-
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
1247
|
-
</div>
|
1248
|
-
</body>
|
1249
|
-
</html>
|