sdl4r 0.9.9 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +70 -1
- data/LICENSE +499 -497
- data/Rakefile +38 -28
- data/TODO +194 -45
- data/doc/classes/SDL4R/AbbreviationTimezoneProxy.html +151 -0
- data/doc/classes/SDL4R/ConstantTimezone.html +129 -0
- data/doc/classes/SDL4R/Element.html +148 -0
- data/doc/classes/SDL4R/Reader.html +683 -0
- data/doc/classes/SDL4R/RelativeTimezone.html +187 -0
- data/doc/classes/SDL4R/SdlBinary.html +188 -0
- data/doc/classes/SDL4R/SdlParseError.html +110 -0
- data/doc/classes/SDL4R/SdlTimeSpan.html +651 -0
- data/doc/classes/SDL4R/Serializer.html +557 -0
- data/doc/classes/SDL4R/Serializer/Ref.html +138 -0
- data/doc/classes/SDL4R/TZAbbreviationDB/Record.html +117 -0
- data/doc/classes/SDL4R/Tag.html +1274 -0
- data/doc/classes/SDL4R/Token.html +131 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGELOG.html +290 -0
- data/doc/files/LICENSE.html +53 -0
- data/doc/files/README.html +405 -0
- data/doc/files/lib/sdl4r/abbreviation_timezone_proxy_rb.html +63 -0
- data/doc/files/lib/sdl4r/constant_timezone_rb.html +54 -0
- data/doc/files/lib/sdl4r/element_rb.html +54 -0
- data/doc/files/lib/sdl4r/reader_rb.html +68 -0
- data/doc/files/lib/sdl4r/relative_timezone_rb.html +62 -0
- data/doc/files/lib/sdl4r/sdl4r_rb.html +66 -0
- data/doc/files/lib/sdl4r/sdl4r_tzinfo_rb.html +64 -0
- data/doc/files/lib/sdl4r/sdl4r_version_rb.html +54 -0
- data/doc/files/lib/sdl4r/sdl_binary_rb.html +54 -0
- data/doc/files/lib/sdl4r/sdl_parse_error_rb.html +54 -0
- data/doc/files/lib/sdl4r/sdl_time_span_rb.html +54 -0
- data/doc/files/lib/sdl4r/serializer_rb.html +62 -0
- data/doc/files/lib/sdl4r/tag_rb.html +66 -0
- data/doc/files/lib/sdl4r/token_rb.html +54 -0
- data/doc/files/lib/sdl4r/tokenizer_rb.html +64 -0
- data/doc/files/lib/sdl4r/tz_abbreviation_db_rb.html +67 -0
- data/doc/files/lib/sdl4r_rb.html +54 -0
- data/doc/files/lib/sdl4r_tzinfo_rb.html +54 -0
- data/doc/fr_class_index.html +23 -0
- data/doc/fr_file_index.html +40 -0
- data/doc/fr_method_index.html +4711 -0
- data/doc/index.html +15 -0
- data/doc/rdoc-style.css +328 -0
- data/lib/sdl4r.rb +3 -1
- data/lib/sdl4r/abbreviation_timezone_proxy.rb +38 -0
- data/lib/sdl4r/constant_timezone.rb +58 -0
- data/{test/sdl4r/sdl_test.rb → lib/sdl4r/element.rb} +19 -14
- data/lib/sdl4r/reader.rb +772 -0
- data/lib/sdl4r/relative_timezone.rb +156 -0
- data/lib/sdl4r/sdl4r.rb +187 -45
- data/lib/sdl4r/sdl4r_tzinfo.rb +75 -0
- data/lib/sdl4r/sdl4r_version.rb +24 -0
- data/lib/sdl4r/sdl_parse_error.rb +1 -1
- data/lib/sdl4r/sdl_time_span.rb +5 -1
- data/lib/sdl4r/serializer.rb +473 -60
- data/lib/sdl4r/tag.rb +126 -51
- data/lib/sdl4r/token.rb +49 -0
- data/lib/sdl4r/tokenizer.rb +431 -0
- data/lib/sdl4r/tz_abbreviation_db.rb +266 -0
- data/read_jprof.html +16934 -0
- data/read_jprof_pull.html +14451 -0
- data/read_prof.html +4983 -0
- data/read_prof_pull.html +4896 -0
- data/test/sdl4r/parser_test.rb +577 -503
- data/test/sdl4r/read_jprof.rb +58 -0
- data/test/sdl4r/read_prof.rb +70 -0
- data/test/sdl4r/reader_test.rb +173 -0
- data/test/sdl4r/relative_timezone_test.rb +102 -0
- data/test/sdl4r/sdl4r_test.rb +611 -528
- data/test/sdl4r/sdl4r_tzinfo_test.rb +108 -0
- data/test/sdl4r/sdl_test_case.rb +60 -0
- data/test/sdl4r/serializer_test.rb +448 -11
- data/test/sdl4r/tag_test.rb +84 -5
- data/test/sdl4r/tokenizer_test.rb +128 -0
- metadata +69 -11
- data/lib/sdl4r/parser.rb +0 -648
- data/lib/sdl4r/parser/reader.rb +0 -184
- data/lib/sdl4r/parser/time_span_with_zone.rb +0 -57
- data/lib/sdl4r/parser/token.rb +0 -138
- data/lib/sdl4r/parser/tokenizer.rb +0 -507
@@ -0,0 +1,138 @@
|
|
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::Serializer::Ref [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::Serializer::Ref
|
31
|
+
</h1>
|
32
|
+
<ol class='paths'>
|
33
|
+
<li>
|
34
|
+
<a href="../../../files/lib/sdl4r/serializer_rb.html">lib/sdl4r/serializer.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
|
+
Represents a reference to an object during serialization or
|
47
|
+
deserialization. Used in order to avoid infinite cycles, repetitions, etc.
|
48
|
+
</p>
|
49
|
+
</div>
|
50
|
+
<div id='method-list'>
|
51
|
+
<h2>Methods</h2>
|
52
|
+
<h3>public class</h3>
|
53
|
+
<ol>
|
54
|
+
<li><a href="#M000104">new</a></li>
|
55
|
+
</ol>
|
56
|
+
<h3>public instance</h3>
|
57
|
+
<ol>
|
58
|
+
<li><a href="#M000105">inc</a></li>
|
59
|
+
</ol>
|
60
|
+
</div>
|
61
|
+
<div id='section'>
|
62
|
+
<div id='attribute-list'>
|
63
|
+
<h2 class='section-bar'>Attributes</h2>
|
64
|
+
<div class='name-list'>
|
65
|
+
<table>
|
66
|
+
<tr class='top-aligned-row context-row'>
|
67
|
+
<td class='context-item-name'>count</td>
|
68
|
+
<td class='context-item-value'>[R]</td>
|
69
|
+
<td class='context-item-desc'></td>
|
70
|
+
</tr>
|
71
|
+
<tr class='top-aligned-row context-row'>
|
72
|
+
<td class='context-item-name'>o</td>
|
73
|
+
<td class='context-item-value'>[R]</td>
|
74
|
+
<td class='context-item-desc'></td>
|
75
|
+
</tr>
|
76
|
+
<tr class='top-aligned-row context-row'>
|
77
|
+
<td class='context-item-name'>oid</td>
|
78
|
+
<td class='context-item-value'>[R]</td>
|
79
|
+
<td class='context-item-desc'></td>
|
80
|
+
</tr>
|
81
|
+
<tr class='top-aligned-row context-row'>
|
82
|
+
<td class='context-item-name'>tag</td>
|
83
|
+
<td class='context-item-value'>[RW]</td>
|
84
|
+
<td class='context-item-desc'></td>
|
85
|
+
</tr>
|
86
|
+
</table>
|
87
|
+
</div>
|
88
|
+
</div>
|
89
|
+
<div id='methods'>
|
90
|
+
<h2>Public class methods</h2>
|
91
|
+
<div class='method public-class' id='method-M000104'>
|
92
|
+
<a name='M000104'></a>
|
93
|
+
<div class='synopsis'>
|
94
|
+
<span class='name'>new</span>
|
95
|
+
<span class='arguments'>(o, oid)</span>
|
96
|
+
</div>
|
97
|
+
<div class='description'>
|
98
|
+
<p>
|
99
|
+
Initializes a reference with a reference counter of 0.
|
100
|
+
</p>
|
101
|
+
</div>
|
102
|
+
<div class='source'>
|
103
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000104-source'); return false">
|
104
|
+
[show source]
|
105
|
+
</a>
|
106
|
+
<pre id='M000104-source'> <span class="ruby-comment cmt"># File lib/sdl4r/serializer.rb, line 89</span>
89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">o</span>, <span class="ruby-identifier">oid</span>)
90: <span class="ruby-ivar">@tag</span> = <span class="ruby-keyword kw">nil</span>
91: <span class="ruby-ivar">@o</span> = <span class="ruby-identifier">o</span>
92: <span class="ruby-ivar">@oid</span> = <span class="ruby-identifier">oid</span>
93: <span class="ruby-ivar">@count</span> = <span class="ruby-value">0</span>
94: <span class="ruby-keyword kw">end</span></pre>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
<h2>Public instance methods</h2>
|
110
|
+
<div class='method public-instance' id='method-M000105'>
|
111
|
+
<a name='M000105'></a>
|
112
|
+
<div class='synopsis'>
|
113
|
+
<span class='name'>inc</span>
|
114
|
+
<span class='arguments'>()</span>
|
115
|
+
</div>
|
116
|
+
<div class='description'>
|
117
|
+
<p>
|
118
|
+
Increments the reference counter by one.
|
119
|
+
</p>
|
120
|
+
</div>
|
121
|
+
<div class='source'>
|
122
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000105-source'); return false">
|
123
|
+
[show source]
|
124
|
+
</a>
|
125
|
+
<pre id='M000105-source'> <span class="ruby-comment cmt"># File lib/sdl4r/serializer.rb, line 98</span>
 98: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inc</span>
 99: <span class="ruby-ivar">@count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
100: <span class="ruby-keyword kw">end</span></pre>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
<div id='footer-push'></div>
|
133
|
+
</div>
|
134
|
+
<div id='footer'>
|
135
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
136
|
+
</div>
|
137
|
+
</body>
|
138
|
+
</html>
|
@@ -0,0 +1,117 @@
|
|
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::TZAbbreviationDB::Record [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::TZAbbreviationDB::Record
|
31
|
+
</h1>
|
32
|
+
<ol class='paths'>
|
33
|
+
<li>
|
34
|
+
<a href="../../../files/lib/sdl4r/tz_abbreviation_db_rb.html">lib/sdl4r/tz_abbreviation_db.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='method-list'>
|
45
|
+
<h2>Methods</h2>
|
46
|
+
<h3>public class</h3>
|
47
|
+
<ol>
|
48
|
+
<li><a href="#M000152">new</a></li>
|
49
|
+
</ol>
|
50
|
+
</div>
|
51
|
+
<div id='section'>
|
52
|
+
<div id='attribute-list'>
|
53
|
+
<h2 class='section-bar'>Attributes</h2>
|
54
|
+
<div class='name-list'>
|
55
|
+
<table>
|
56
|
+
<tr class='top-aligned-row context-row'>
|
57
|
+
<td class='context-item-name'>annotation</td>
|
58
|
+
<td class='context-item-value'>[RW]</td>
|
59
|
+
<td class='context-item-desc'>
|
60
|
+
|
61
|
+
:not_ambiguous :time_ambiguous :modern_time_ambiguous :too_ambiguous
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
<tr class='top-aligned-row context-row'>
|
65
|
+
<td class='context-item-name'>identifier</td>
|
66
|
+
<td class='context-item-value'>[R]</td>
|
67
|
+
<td class='context-item-desc'></td>
|
68
|
+
</tr>
|
69
|
+
<tr class='top-aligned-row context-row'>
|
70
|
+
<td class='context-item-name'>linked_zone_ids</td>
|
71
|
+
<td class='context-item-value'>[RW]</td>
|
72
|
+
<td class='context-item-desc'></td>
|
73
|
+
</tr>
|
74
|
+
<tr class='top-aligned-row context-row'>
|
75
|
+
<td class='context-item-name'>std_offset</td>
|
76
|
+
<td class='context-item-value'>[R]</td>
|
77
|
+
<td class='context-item-desc'></td>
|
78
|
+
</tr>
|
79
|
+
<tr class='top-aligned-row context-row'>
|
80
|
+
<td class='context-item-name'>use</td>
|
81
|
+
<td class='context-item-value'>[R]</td>
|
82
|
+
<td class='context-item-desc'></td>
|
83
|
+
</tr>
|
84
|
+
<tr class='top-aligned-row context-row'>
|
85
|
+
<td class='context-item-name'>utc_offset</td>
|
86
|
+
<td class='context-item-value'>[R]</td>
|
87
|
+
<td class='context-item-desc'></td>
|
88
|
+
</tr>
|
89
|
+
</table>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
<div id='methods'>
|
93
|
+
<h2>Public class methods</h2>
|
94
|
+
<div class='method public-class' id='method-M000152'>
|
95
|
+
<a name='M000152'></a>
|
96
|
+
<div class='synopsis'>
|
97
|
+
<span class='name'>new</span>
|
98
|
+
<span class='arguments'>(identifier, utc_offset, std_offset, annotation, use, linked_zone_ids)</span>
|
99
|
+
</div>
|
100
|
+
<div class='source'>
|
101
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000152-source'); return false">
|
102
|
+
[show source]
|
103
|
+
</a>
|
104
|
+
<pre id='M000152-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tz_abbreviation_db.rb, line 66</span>
66: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">identifier</span>, <span class="ruby-identifier">utc_offset</span>, <span class="ruby-identifier">std_offset</span>, <span class="ruby-identifier">annotation</span>, <span class="ruby-identifier">use</span>, <span class="ruby-identifier">linked_zone_ids</span>)
67: <span class="ruby-ivar">@identifier</span> = <span class="ruby-identifier">identifier</span>
68: <span class="ruby-ivar">@utc_offset</span> = <span class="ruby-identifier">utc_offset</span>
69: <span class="ruby-ivar">@std_offset</span> = <span class="ruby-identifier">std_offset</span>
70: <span class="ruby-ivar">@annotation</span> = <span class="ruby-identifier">annotation</span>
71: <span class="ruby-ivar">@use</span> = <span class="ruby-identifier">use</span>
72: <span class="ruby-ivar">@linked_zone_ids</span> = <span class="ruby-identifier">linked_zone_ids</span>
73: <span class="ruby-keyword kw">end</span></pre>
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
<div id='footer-push'></div>
|
112
|
+
</div>
|
113
|
+
<div id='footer'>
|
114
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
115
|
+
</div>
|
116
|
+
</body>
|
117
|
+
</html>
|
@@ -0,0 +1,1274 @@
|
|
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="#M000106">new</a></li>
|
70
|
+
</ol>
|
71
|
+
<h3>public instance</h3>
|
72
|
+
<ol>
|
73
|
+
<li><a href="#M000109"><<</a></li>
|
74
|
+
<li><a href="#M000147">==</a></li>
|
75
|
+
<li><a href="#M000108">add_child</a></li>
|
76
|
+
<li><a href="#M000122">add_value</a></li>
|
77
|
+
<li><a href="#M000130">attribute</a></li>
|
78
|
+
<li><a href="#M000133">attributes</a></li>
|
79
|
+
<li><a href="#M000137">attributes=</a></li>
|
80
|
+
<li><a href="#M000117">child</a></li>
|
81
|
+
<li><a href="#M000114">child_count</a></li>
|
82
|
+
<li><a href="#M000115">children</a></li>
|
83
|
+
<li><a href="#M000145">children_to_string</a></li>
|
84
|
+
<li><a href="#M000116">children_values</a></li>
|
85
|
+
<li><a href="#M000135">clear_attributes</a></li>
|
86
|
+
<li><a href="#M000111">clear_children</a></li>
|
87
|
+
<li><a href="#M000125">clear_values</a></li>
|
88
|
+
<li><a href="#M000146">eql?</a></li>
|
89
|
+
<li><a href="#M000131">has_attribute?</a></li>
|
90
|
+
<li><a href="#M000132">has_attributes?</a></li>
|
91
|
+
<li><a href="#M000118">has_child?</a></li>
|
92
|
+
<li><a href="#M000119">has_children?</a></li>
|
93
|
+
<li><a href="#M000123">has_value?</a></li>
|
94
|
+
<li><a href="#M000128">has_values?</a></li>
|
95
|
+
<li><a href="#M000148">hash</a></li>
|
96
|
+
<li><a href="#M000138">name=</a></li>
|
97
|
+
<li><a href="#M000139">namespace=</a></li>
|
98
|
+
<li><a href="#M000107">new_child</a></li>
|
99
|
+
<li><a href="#M000140">read</a></li>
|
100
|
+
<li><a href="#M000141">read_from_io</a></li>
|
101
|
+
<li><a href="#M000134">remove_attribute</a></li>
|
102
|
+
<li><a href="#M000110">remove_child</a></li>
|
103
|
+
<li><a href="#M000124">remove_value</a></li>
|
104
|
+
<li><a href="#M000129">set_attribute</a></li>
|
105
|
+
<li><a href="#M000136">set_attributes</a></li>
|
106
|
+
<li><a href="#M000120">to_child_hash</a></li>
|
107
|
+
<li><a href="#M000121">to_child_string_hash</a></li>
|
108
|
+
<li><a href="#M000143">to_s</a></li>
|
109
|
+
<li><a href="#M000144">to_string</a></li>
|
110
|
+
<li><a href="#M000149">to_xml_string</a></li>
|
111
|
+
<li><a href="#M000113">value</a></li>
|
112
|
+
<li><a href="#M000112">value=</a></li>
|
113
|
+
<li><a href="#M000126">values</a></li>
|
114
|
+
<li><a href="#M000127">values=</a></li>
|
115
|
+
<li><a href="#M000142">write</a></li>
|
116
|
+
</ol>
|
117
|
+
<h3>protected instance</h3>
|
118
|
+
<ol>
|
119
|
+
<li><a href="#M000150">_to_xml_string</a></li>
|
120
|
+
</ol>
|
121
|
+
</div>
|
122
|
+
<div id='section'>
|
123
|
+
<div id='attribute-list'>
|
124
|
+
<h2 class='section-bar'>Attributes</h2>
|
125
|
+
<div class='name-list'>
|
126
|
+
<table>
|
127
|
+
<tr class='top-aligned-row context-row'>
|
128
|
+
<td class='context-item-name'>name</td>
|
129
|
+
<td class='context-item-value'>[R]</td>
|
130
|
+
<td class='context-item-desc'>
|
131
|
+
|
132
|
+
the name of this <a href="Tag.html">Tag</a>
|
133
|
+
</td>
|
134
|
+
</tr>
|
135
|
+
<tr class='top-aligned-row context-row'>
|
136
|
+
<td class='context-item-name'>namespace</td>
|
137
|
+
<td class='context-item-value'>[R]</td>
|
138
|
+
<td class='context-item-desc'>
|
139
|
+
|
140
|
+
the namespace of this <a href="Tag.html">Tag</a> or an empty string when
|
141
|
+
there is no namespace (i.e. default namespace).
|
142
|
+
</td>
|
143
|
+
</tr>
|
144
|
+
</table>
|
145
|
+
</div>
|
146
|
+
</div>
|
147
|
+
<div id='methods'>
|
148
|
+
<h2>Public class methods</h2>
|
149
|
+
<div class='method public-class' id='method-M000106'>
|
150
|
+
<a name='M000106'></a>
|
151
|
+
<div class='synopsis'>
|
152
|
+
<span class='name'>new</span>
|
153
|
+
<span class='arguments'>(namespace, name = nil, &block)</span>
|
154
|
+
</div>
|
155
|
+
<div class='description'>
|
156
|
+
<p>
|
157
|
+
Creates an empty tag in the given namespace. If the <tt>namespace</tt> is
|
158
|
+
nil it will be coerced to an empty String.
|
159
|
+
</p>
|
160
|
+
<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>
|
161
|
+
<p>
|
162
|
+
which builds the following SDL structure
|
163
|
+
</p>
|
164
|
+
<pre>fruit 2 {
 orange quantity=2
}</pre>
|
165
|
+
<p>
|
166
|
+
If you provide a block that takes an argument, you will write the same
|
167
|
+
example, as follows:
|
168
|
+
</p>
|
169
|
+
<pre>tag = Tag.new("fruit") do |t|
 t.add_value 2
 t.new_child("orange") do
 set_attribute("quantity", 2)
 end
end</pre>
|
170
|
+
<p>
|
171
|
+
In this case, the current context is not the new <a href="Tag.html">Tag</a>
|
172
|
+
anymore but the context of your code.
|
173
|
+
</p>
|
174
|
+
<h3>Raises</h3>
|
175
|
+
<p>
|
176
|
+
ArgumentError if the name is not a legal SDL identifier (see
|
177
|
+
SDL4R#validate_identifier) or the namespace is non-blank and is not a legal
|
178
|
+
SDL identifier.
|
179
|
+
</p>
|
180
|
+
</div>
|
181
|
+
<div class='source'>
|
182
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000106-source'); return false">
|
183
|
+
[show source]
|
184
|
+
</a>
|
185
|
+
<pre id='M000106-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 142</span>
142: <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>)
143: <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span> = <span class="ruby-identifier">to_ns_n</span> <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span>
144: 
145: 
146: <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>
147: <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>
148: 
149: <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>
150: <span class="ruby-ivar">@namespace</span> = <span class="ruby-identifier">namespace</span>
151: 
152: <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>
153: <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>
154: <span class="ruby-constant">SDL4R</span>.<span class="ruby-identifier">validate_identifier</span>(<span class="ruby-identifier">name</span>)
155: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
156: 
157: <span class="ruby-ivar">@children</span> = []
158: <span class="ruby-ivar">@values</span> = []
159: 
160: <span class="ruby-comment cmt"># a Hash of Hash : {namespace => {name => value}}</span>
161: <span class="ruby-comment cmt"># The default namespace is represented by an empty string.</span>
162: <span class="ruby-ivar">@attributesByNamespace</span> = {}
163: 
164: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
165: <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>
166: <span class="ruby-identifier">block</span>[<span class="ruby-keyword kw">self</span>]
167: <span class="ruby-keyword kw">else</span>
168: <span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
169: <span class="ruby-keyword kw">end</span>
170: <span class="ruby-keyword kw">end</span>
171: <span class="ruby-keyword kw">end</span></pre>
|
186
|
+
</div>
|
187
|
+
</div>
|
188
|
+
<h2>Public instance methods</h2>
|
189
|
+
<div class='method public-instance' id='method-M000109'>
|
190
|
+
<a name='M000109'></a>
|
191
|
+
<div class='synopsis'>
|
192
|
+
<span class='name'><<</span>
|
193
|
+
<span class='arguments'>(o)</span>
|
194
|
+
</div>
|
195
|
+
<div class='description'>
|
196
|
+
<p>
|
197
|
+
Adds the given object as a child if it is a <tt>Tag</tt>, as an attribute
|
198
|
+
if it is a Hash {key => value} (supports namespaces), or as a value
|
199
|
+
otherwise. If it is an Enumerable (e.g. Array), each of its elements is
|
200
|
+
added to this <a href="Tag.html">Tag</a> via this operator. If any of its
|
201
|
+
elements is itself an Enumerable, then an anonymous tag is created and the
|
202
|
+
Enumerable is passed to it via this operator (see the examples below).
|
203
|
+
</p>
|
204
|
+
<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>
|
205
|
+
<p>
|
206
|
+
Of course, despite the fact that String is an Enumerable, it is considered
|
207
|
+
as the type of values.
|
208
|
+
</p>
|
209
|
+
<p>
|
210
|
+
Returns <tt>self</tt>.
|
211
|
+
</p>
|
212
|
+
<p>
|
213
|
+
Use other accessors (<a href="Tag.html#M000108">add_child</a>, <a
|
214
|
+
href="Tag.html#M000122">add_value</a>, <a
|
215
|
+
href="Tag.html#M000133">attributes</a>, etc) for a stricter and less
|
216
|
+
“magical” behavior.
|
217
|
+
</p>
|
218
|
+
</div>
|
219
|
+
<div class='source'>
|
220
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000109-source'); return false">
|
221
|
+
[show source]
|
222
|
+
</a>
|
223
|
+
<pre id='M000109-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-operator"><<</span>(<span class="ruby-identifier">o</span>)
237: <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>)
238: <span class="ruby-identifier">add_child</span>(<span class="ruby-identifier">o</span>)
239: <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>)
240: <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>
241: <span class="ruby-identifier">key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Symbol</span>
242: <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>)
243: <span class="ruby-identifier">namespace</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">""</span>
244: <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>)
245: }
246: <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>
247: <span class="ruby-identifier">add_value</span>(<span class="ruby-identifier">o</span>)
248: <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>
249: <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>
250: <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>
251: <span class="ruby-identifier">anonymous</span> = <span class="ruby-identifier">new_child</span>(<span class="ruby-constant">ANONYMOUS_TAG_NAME</span>)
252: <span class="ruby-identifier">anonymous</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">item</span>
253: <span class="ruby-keyword kw">else</span>
254: <span class="ruby-keyword kw">self</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">item</span>
255: <span class="ruby-keyword kw">end</span>
256: }
257: <span class="ruby-keyword kw">else</span>
258: <span class="ruby-identifier">add_value</span>(<span class="ruby-identifier">o</span>)
259: <span class="ruby-keyword kw">end</span>
260: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
261: <span class="ruby-keyword kw">end</span></pre>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
<div class='method public-instance' id='method-M000147'>
|
227
|
+
<a name='M000147'></a>
|
228
|
+
<div class='synopsis'>
|
229
|
+
<span class='name'>==</span>
|
230
|
+
<span class='arguments'>(o)</span>
|
231
|
+
</div>
|
232
|
+
<div class='description'>
|
233
|
+
<p>
|
234
|
+
Alias for <a href="Tag.html#M000146">eql?</a>
|
235
|
+
</p>
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
<div class='method public-instance' id='method-M000108'>
|
239
|
+
<a name='M000108'></a>
|
240
|
+
<div class='synopsis'>
|
241
|
+
<span class='name'>add_child</span>
|
242
|
+
<span class='arguments'>(child)</span>
|
243
|
+
</div>
|
244
|
+
<div class='description'>
|
245
|
+
<p>
|
246
|
+
Add a child to this <a href="Tag.html">Tag</a>.
|
247
|
+
</p>
|
248
|
+
<table>
|
249
|
+
<tr><td valign="top"><em>child</em>:</td><td>The child to add
|
250
|
+
|
251
|
+
</td></tr>
|
252
|
+
</table>
|
253
|
+
<p>
|
254
|
+
Returns the added child.
|
255
|
+
</p>
|
256
|
+
</div>
|
257
|
+
<div class='source'>
|
258
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000108-source'); return false">
|
259
|
+
[show source]
|
260
|
+
</a>
|
261
|
+
<pre id='M000108-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 204</span>
204: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_child</span>(<span class="ruby-identifier">child</span>)
205: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"child is nil"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">child</span>
206: <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">child</span>)
207: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">child</span>
208: <span class="ruby-keyword kw">end</span></pre>
|
262
|
+
</div>
|
263
|
+
</div>
|
264
|
+
<div class='method public-instance' id='method-M000122'>
|
265
|
+
<a name='M000122'></a>
|
266
|
+
<div class='synopsis'>
|
267
|
+
<span class='name'>add_value</span>
|
268
|
+
<span class='arguments'>(v)</span>
|
269
|
+
</div>
|
270
|
+
<div class='description'>
|
271
|
+
<p>
|
272
|
+
Adds a value to this <a href="Tag.html">Tag</a>. See SDL4R#coerce_or_fail
|
273
|
+
to know about the allowable types.
|
274
|
+
</p>
|
275
|
+
<table>
|
276
|
+
<tr><td valign="top"><em>v</em>:</td><td>The value to add
|
277
|
+
|
278
|
+
</td></tr>
|
279
|
+
</table>
|
280
|
+
<p>
|
281
|
+
Raises an <tt>ArgumentError</tt> if the value is not a legal SDL type
|
282
|
+
</p>
|
283
|
+
</div>
|
284
|
+
<div class='source'>
|
285
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000122-source'); return false">
|
286
|
+
[show source]
|
287
|
+
</a>
|
288
|
+
<pre id='M000122-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 485</span>
485: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_value</span>(<span class="ruby-identifier">v</span>)
486: <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>))
487: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
488: <span class="ruby-keyword kw">end</span></pre>
|
289
|
+
</div>
|
290
|
+
</div>
|
291
|
+
<div class='method public-instance' id='method-M000130'>
|
292
|
+
<a name='M000130'></a>
|
293
|
+
<div class='synopsis'>
|
294
|
+
<span class='name'>attribute</span>
|
295
|
+
<span class='arguments'>(namespace, key = nil)</span>
|
296
|
+
</div>
|
297
|
+
<div class='description'>
|
298
|
+
<pre>attribute(key)
attribute(namespace, key)</pre>
|
299
|
+
<p>
|
300
|
+
Returns the attribute of the specified <tt>namespace</tt> of specified
|
301
|
+
<tt>key</tt> or <tt>nil</tt> if not found.
|
302
|
+
</p>
|
303
|
+
</div>
|
304
|
+
<div class='source'>
|
305
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000130-source'); return false">
|
306
|
+
[show source]
|
307
|
+
</a>
|
308
|
+
<pre id='M000130-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 596</span>
596: <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>)
597: <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span> = <span class="ruby-identifier">to_ns_n</span> <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">key</span>
598: <span class="ruby-identifier">attributes</span> = <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
599: <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>]
600: <span class="ruby-keyword kw">end</span></pre>
|
309
|
+
</div>
|
310
|
+
</div>
|
311
|
+
<div class='method public-instance' id='method-M000133'>
|
312
|
+
<a name='M000133'></a>
|
313
|
+
<div class='synopsis'>
|
314
|
+
<span class='name'>attributes</span>
|
315
|
+
<span class='arguments'>(namespace = nil) {|namespace, key, value| ...}</span>
|
316
|
+
</div>
|
317
|
+
<div class='description'>
|
318
|
+
<p>
|
319
|
+
Returns a Hash of the attributes of the specified <tt>namespace</tt>
|
320
|
+
(default is all) or enumerates them.
|
321
|
+
</p>
|
322
|
+
<pre>tag.attributes # => { "length" => 123, "width" = 25.4, "orig:color" => "gray" }
tag.attributes("orig") do |namespace, key, value|
 p "#{namespace}:#{key} = #{value}"
end</pre>
|
323
|
+
<p>
|
324
|
+
<em>namespace</em>:: namespace of the returned attributes. If nil, all
|
325
|
+
attributes are returned with qualified names (e.g.
|
326
|
+
“meat:color”). If “”, attributes of the default
|
327
|
+
namespace are returned.
|
328
|
+
</p>
|
329
|
+
</div>
|
330
|
+
<div class='source'>
|
331
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000133-source'); return false">
|
332
|
+
[show source]
|
333
|
+
</a>
|
334
|
+
<pre id='M000133-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 638</span>
638: <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>
639: <span class="ruby-identifier">namespace</span> = <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">id2name</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Symbol</span>
640: 
641: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
642: <span class="ruby-identifier">each_attribute</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
643: 
644: <span class="ruby-keyword kw">else</span>
645: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">nil?</span>
646: <span class="ruby-identifier">hash</span> = {}
647: 
648: <span class="ruby-identifier">each_attribute</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">attr_namespace</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span> <span class="ruby-operator">|</span>
649: <span class="ruby-identifier">qualified_name</span> = <span class="ruby-identifier">attr_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">attr_namespace</span> <span class="ruby-operator">+</span> <span class="ruby-value str">':'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>
650: <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">qualified_name</span>] = <span class="ruby-identifier">value</span>
651: <span class="ruby-keyword kw">end</span>
652: 
653: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">hash</span>
654: 
655: <span class="ruby-keyword kw">else</span>
656: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@attributesByNamespace</span>[<span class="ruby-identifier">namespace</span>]
657: <span class="ruby-keyword kw">end</span>
658: <span class="ruby-keyword kw">end</span>
659: <span class="ruby-keyword kw">end</span></pre>
|
335
|
+
</div>
|
336
|
+
</div>
|
337
|
+
<div class='method public-instance' id='method-M000137'>
|
338
|
+
<a name='M000137'></a>
|
339
|
+
<div class='synopsis'>
|
340
|
+
<span class='name'>attributes=</span>
|
341
|
+
<span class='arguments'>(attribute_hash)</span>
|
342
|
+
</div>
|
343
|
+
<div class='description'>
|
344
|
+
<p>
|
345
|
+
Sets all the attributes of the default namespace for this <a
|
346
|
+
href="Tag.html">Tag</a> in one operation.
|
347
|
+
</p>
|
348
|
+
<p>
|
349
|
+
See <a href="Tag.html#M000136">set_attributes</a>.
|
350
|
+
</p>
|
351
|
+
</div>
|
352
|
+
<div class='source'>
|
353
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000137-source'); return false">
|
354
|
+
[show source]
|
355
|
+
</a>
|
356
|
+
<pre id='M000137-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 744</span>
744: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">attributes=</span>(<span class="ruby-identifier">attribute_hash</span>)
745: <span class="ruby-identifier">set_attributes</span>(<span class="ruby-identifier">attribute_hash</span>)
746: <span class="ruby-keyword kw">end</span></pre>
|
357
|
+
</div>
|
358
|
+
</div>
|
359
|
+
<div class='method public-instance' id='method-M000117'>
|
360
|
+
<a name='M000117'></a>
|
361
|
+
<div class='synopsis'>
|
362
|
+
<span class='name'>child</span>
|
363
|
+
<span class='arguments'>(*args)</span>
|
364
|
+
</div>
|
365
|
+
<div class='description'>
|
366
|
+
<pre>child # => first child
child(name) # => first child of specified name (any namespace)
child(true, name) # => first child (or descendant) of specified name (any namspace)
child(namespace, name) # => first child of specified namespace and name
child(recursive, namespace, name)</pre>
|
367
|
+
<p>
|
368
|
+
Get the first child with the given name, optionally using a recursive
|
369
|
+
search.
|
370
|
+
</p>
|
371
|
+
<table>
|
372
|
+
<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
|
373
|
+
first child is returned (<tt>nil</tt> if there are
|
374
|
+
|
375
|
+
</td></tr>
|
376
|
+
</table>
|
377
|
+
<p>
|
378
|
+
no children at all).
|
379
|
+
</p>
|
380
|
+
<p>
|
381
|
+
Returns the first child tag having the given name or <tt>nil</tt> if no
|
382
|
+
such child exists
|
383
|
+
</p>
|
384
|
+
</div>
|
385
|
+
<div class='source'>
|
386
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000117-source'); return false">
|
387
|
+
[show source]
|
388
|
+
</a>
|
389
|
+
<pre id='M000117-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 384</span>
384: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">child</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
385: <span class="ruby-identifier">recursive</span>, <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">name</span> = <span class="ruby-identifier">to_rec_ns_n</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
386: 
387: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">nil?</span>
388: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">first</span>
389: <span class="ruby-keyword kw">else</span>
390: <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> <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">child</span> }
391: <span class="ruby-keyword kw">end</span>
392: <span class="ruby-keyword kw">end</span></pre>
|
390
|
+
</div>
|
391
|
+
</div>
|
392
|
+
<div class='method public-instance' id='method-M000114'>
|
393
|
+
<a name='M000114'></a>
|
394
|
+
<div class='synopsis'>
|
395
|
+
<span class='name'>child_count</span>
|
396
|
+
<span class='arguments'>()</span>
|
397
|
+
</div>
|
398
|
+
<div class='description'>
|
399
|
+
<p>
|
400
|
+
Returns the number of children <a href="Tag.html">Tag</a>.
|
401
|
+
</p>
|
402
|
+
</div>
|
403
|
+
<div class='source'>
|
404
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000114-source'); return false">
|
405
|
+
[show source]
|
406
|
+
</a>
|
407
|
+
<pre id='M000114-source'> <span class="ruby-comment cmt"># File lib/sdl4r/tag.rb, line 304</span>
304: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">child_count</span>
305: <span class="ruby-ivar">@children</span>.<span class="ruby-identifier">size</span>
306: <span class="ruby-keyword kw">end</span></pre>
|
408
|
+
</div>
|
409
|
+
</div>
|
410
|
+
<div class='method public-instance' id='method-M000115'>
|
411
|
+
<a name='M000115'></a>
|
412
|
+
<div class='synopsis'>
|
413
|
+
<span class='name'>children</span>
|
414
|
+
<span class='arguments'>(*args) {|child| ...}</span>
|
415
|
+
</div>
|
416
|
+
<div class='description'>
|
417
|
+
<pre>children(recursive)
children(recursive, name)
children(recursive, namespace, name)

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