atom-tools 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/doc/classes/Atom/AttrEl.html +163 -0
- data/doc/classes/Atom/Author.html +113 -0
- data/doc/classes/Atom/AutodiscoveryFailure.html +111 -0
- data/doc/classes/Atom/Categories.html +168 -0
- data/doc/classes/Atom/Category.html +137 -0
- data/doc/classes/Atom/Collection.html +425 -0
- data/doc/classes/Atom/Content.html +170 -0
- data/doc/classes/Atom/Contributor.html +113 -0
- data/doc/classes/Atom/Control.html +126 -0
- data/doc/classes/Atom/Converters.html +571 -0
- data/doc/classes/Atom/DigestAuth.html +285 -0
- data/doc/classes/Atom/Element.html +892 -0
- data/doc/classes/Atom/FileCache.html +287 -0
- data/doc/classes/Atom/HTTP.html +490 -0
- data/doc/classes/Atom/HTTPResponse.html +190 -0
- data/doc/classes/Atom/HasCategories.html +187 -0
- data/doc/classes/Atom/HasLinks.html +168 -0
- data/doc/classes/Atom/Link.html +214 -0
- data/doc/classes/Atom/NilCache.html +202 -0
- data/doc/classes/Atom/ParseError.html +111 -0
- data/doc/classes/Atom/Parsers.html +311 -0
- data/doc/classes/Atom/Person.html +130 -0
- data/doc/classes/Atom/Rights.html +113 -0
- data/doc/classes/Atom/Service.html +298 -0
- data/doc/classes/Atom/Source.html +111 -0
- data/doc/classes/Atom/Subtitle.html +113 -0
- data/doc/classes/Atom/Summary.html +113 -0
- data/doc/classes/Atom/Text.html +372 -0
- data/doc/classes/Atom/Title.html +113 -0
- data/doc/classes/Atom/Tools.html +525 -0
- data/doc/classes/Atom/Workspace.html +121 -0
- data/doc/classes/Object.html +204 -0
- data/doc/classes/XHTML.html +118 -0
- data/doc/created.rid +1 -0
- data/doc/files/README.html +173 -0
- data/doc/files/lib/atom/cache_rb.html +302 -0
- data/doc/files/lib/atom/collection_rb.html +109 -0
- data/doc/files/lib/atom/element_rb.html +110 -0
- data/doc/files/lib/atom/entry_rb.html +111 -0
- data/doc/files/lib/atom/feed_rb.html +111 -0
- data/doc/files/lib/atom/http_rb.html +114 -0
- data/doc/files/lib/atom/service_rb.html +112 -0
- data/doc/files/lib/atom/text_rb.html +109 -0
- data/doc/files/lib/atom/tools_rb.html +108 -0
- data/doc/fr_class_index.html +59 -0
- data/doc/fr_file_index.html +36 -0
- data/doc/fr_method_index.html +137 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/atom/cache.rb +1 -1
- data/lib/atom/http.rb +2 -2
- data/lib/atom/text.rb +15 -6
- data/spec/entry_spec.rb +12 -1
- data/spec/feed_spec.rb +20 -1
- data/spec/fixtures/contacts-feed.xml +34 -0
- data/spec/fixtures/entry-w-xml.xml +24 -0
- metadata +68 -5
@@ -0,0 +1,113 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Atom::Summary</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Atom::Summary</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/atom/text_rb.html">
|
59
|
+
lib/atom/text.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="Text.html">
|
69
|
+
Atom::Text
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
<!-- if includes -->
|
92
|
+
|
93
|
+
<div id="section">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<!-- if method_list -->
|
103
|
+
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<div id="validator-badges">
|
109
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
</body>
|
113
|
+
</html>
|
@@ -0,0 +1,372 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Atom::Text</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Atom::Text</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/atom/text_rb.html">
|
59
|
+
lib/atom/text.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="Element.html">
|
69
|
+
Atom::Element
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
An <a href="Element.html">Atom::Element</a> representing a text construct.
|
86
|
+
It has a single attribute, "<a
|
87
|
+
href="Text.html#M000052">type</a>", which specifies how to interpret
|
88
|
+
the element‘s content. Different types are:
|
89
|
+
</p>
|
90
|
+
<table>
|
91
|
+
<tr><td valign="top">text:</td><td>a plain string, without any markup (default)
|
92
|
+
|
93
|
+
</td></tr>
|
94
|
+
<tr><td valign="top"><a href="Text.html#M000054">html</a>:</td><td>a chunk of HTML
|
95
|
+
|
96
|
+
</td></tr>
|
97
|
+
<tr><td valign="top">xhtml:</td><td>a chunk of *well-formed* <a href="../XHTML.html">XHTML</a>
|
98
|
+
|
99
|
+
</td></tr>
|
100
|
+
</table>
|
101
|
+
<p>
|
102
|
+
You should set this attribute appropriately after you set a <a
|
103
|
+
href="Text.html">Text</a> element (entry.content, entry.title or
|
104
|
+
entry.summary).
|
105
|
+
</p>
|
106
|
+
<p>
|
107
|
+
This content of this element can be retrieved in different formats, see <a
|
108
|
+
href="Text.html#M000054">html</a> and <a href="Text.html#M000055">xml</a>
|
109
|
+
</p>
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div id="method-list">
|
117
|
+
<h3 class="section-bar">Methods</h3>
|
118
|
+
|
119
|
+
<div class="name-list">
|
120
|
+
<a href="#M000054">html</a>
|
121
|
+
<a href="#M000051">new</a>
|
122
|
+
<a href="#M000053">to_s</a>
|
123
|
+
<a href="#M000052">type</a>
|
124
|
+
<a href="#M000056">type=</a>
|
125
|
+
<a href="#M000055">xml</a>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
<!-- if includes -->
|
133
|
+
<div id="includes">
|
134
|
+
<h3 class="section-bar">Included Modules</h3>
|
135
|
+
|
136
|
+
<div id="includes-list">
|
137
|
+
<span class="include-name"><a href="AttrEl.html">AttrEl</a></span>
|
138
|
+
</div>
|
139
|
+
</div>
|
140
|
+
|
141
|
+
<div id="section">
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
<!-- if method_list -->
|
151
|
+
<div id="methods">
|
152
|
+
<h3 class="section-bar">Public Class methods</h3>
|
153
|
+
|
154
|
+
<div id="method-M000051" class="method-detail">
|
155
|
+
<a name="M000051"></a>
|
156
|
+
|
157
|
+
<div class="method-heading">
|
158
|
+
<a href="#M000051" class="method-signature">
|
159
|
+
<span class="method-name">new</span><span class="method-args">(value = nil)</span>
|
160
|
+
</a>
|
161
|
+
</div>
|
162
|
+
|
163
|
+
<div class="method-description">
|
164
|
+
<p><a class="source-toggle" href="#"
|
165
|
+
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
166
|
+
<div class="method-source-code" id="M000051-source">
|
167
|
+
<pre>
|
168
|
+
<span class="ruby-comment cmt"># File lib/atom/text.rb, line 73</span>
|
169
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>
|
170
|
+
<span class="ruby-keyword kw">super</span>()
|
171
|
+
|
172
|
+
<span class="ruby-ivar">@content</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:to_xml</span>
|
173
|
+
<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_xml</span>[<span class="ruby-value">0</span>]
|
174
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">value</span>
|
175
|
+
<span class="ruby-identifier">value</span>
|
176
|
+
<span class="ruby-keyword kw">else</span>
|
177
|
+
<span class="ruby-value str">''</span>
|
178
|
+
<span class="ruby-keyword kw">end</span>
|
179
|
+
<span class="ruby-keyword kw">end</span>
|
180
|
+
</pre>
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
186
|
+
|
187
|
+
<div id="method-M000054" class="method-detail">
|
188
|
+
<a name="M000054"></a>
|
189
|
+
|
190
|
+
<div class="method-heading">
|
191
|
+
<a href="#M000054" class="method-signature">
|
192
|
+
<span class="method-name">html</span><span class="method-args">()</span>
|
193
|
+
</a>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="method-description">
|
197
|
+
<p>
|
198
|
+
returns a string suitable for dumping into an HTML document.
|
199
|
+
</p>
|
200
|
+
<pre>
|
201
|
+
(or nil if that's impossible)
|
202
|
+
</pre>
|
203
|
+
<p>
|
204
|
+
if you‘re storing the content of a <a href="Text.html">Text</a>
|
205
|
+
construct, you probably want this representation.
|
206
|
+
</p>
|
207
|
+
<p><a class="source-toggle" href="#"
|
208
|
+
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
209
|
+
<div class="method-source-code" id="M000054-source">
|
210
|
+
<pre>
|
211
|
+
<span class="ruby-comment cmt"># File lib/atom/text.rb, line 102</span>
|
212
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">html</span>
|
213
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"xhtml"</span> <span class="ruby-keyword kw">or</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"html"</span>
|
214
|
+
<span class="ruby-identifier">to_s</span>
|
215
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"text"</span>
|
216
|
+
<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Text</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_s</span>
|
217
|
+
<span class="ruby-keyword kw">end</span>
|
218
|
+
<span class="ruby-keyword kw">end</span>
|
219
|
+
</pre>
|
220
|
+
</div>
|
221
|
+
</div>
|
222
|
+
</div>
|
223
|
+
|
224
|
+
<div id="method-M000053" class="method-detail">
|
225
|
+
<a name="M000053"></a>
|
226
|
+
|
227
|
+
<div class="method-heading">
|
228
|
+
<a href="#M000053" class="method-signature">
|
229
|
+
<span class="method-name">to_s</span><span class="method-args">()</span>
|
230
|
+
</a>
|
231
|
+
</div>
|
232
|
+
|
233
|
+
<div class="method-description">
|
234
|
+
<p><a class="source-toggle" href="#"
|
235
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
236
|
+
<div class="method-source-code" id="M000053-source">
|
237
|
+
<pre>
|
238
|
+
<span class="ruby-comment cmt"># File lib/atom/text.rb, line 89</span>
|
239
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
240
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'xhtml'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@content</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@content</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'div'</span>
|
241
|
+
<span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">to_s</span>
|
242
|
+
<span class="ruby-keyword kw">else</span>
|
243
|
+
<span class="ruby-ivar">@content</span>.<span class="ruby-identifier">to_s</span>
|
244
|
+
<span class="ruby-keyword kw">end</span>
|
245
|
+
<span class="ruby-keyword kw">end</span>
|
246
|
+
</pre>
|
247
|
+
</div>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
<div id="method-M000052" class="method-detail">
|
252
|
+
<a name="M000052"></a>
|
253
|
+
|
254
|
+
<div class="method-heading">
|
255
|
+
<a href="#M000052" class="method-signature">
|
256
|
+
<span class="method-name">type</span><span class="method-args">()</span>
|
257
|
+
</a>
|
258
|
+
</div>
|
259
|
+
|
260
|
+
<div class="method-description">
|
261
|
+
<p><a class="source-toggle" href="#"
|
262
|
+
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
263
|
+
<div class="method-source-code" id="M000052-source">
|
264
|
+
<pre>
|
265
|
+
<span class="ruby-comment cmt"># File lib/atom/text.rb, line 85</span>
|
266
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type</span>
|
267
|
+
<span class="ruby-ivar">@type</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@type</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'text'</span>
|
268
|
+
<span class="ruby-keyword kw">end</span>
|
269
|
+
</pre>
|
270
|
+
</div>
|
271
|
+
</div>
|
272
|
+
</div>
|
273
|
+
|
274
|
+
<div id="method-M000056" class="method-detail">
|
275
|
+
<a name="M000056"></a>
|
276
|
+
|
277
|
+
<div class="method-heading">
|
278
|
+
<a href="#M000056" class="method-signature">
|
279
|
+
<span class="method-name">type=</span><span class="method-args">(value)</span>
|
280
|
+
</a>
|
281
|
+
</div>
|
282
|
+
|
283
|
+
<div class="method-description">
|
284
|
+
<p><a class="source-toggle" href="#"
|
285
|
+
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
286
|
+
<div class="method-source-code" id="M000056-source">
|
287
|
+
<pre>
|
288
|
+
<span class="ruby-comment cmt"># File lib/atom/text.rb, line 143</span>
|
289
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type=</span> <span class="ruby-identifier">value</span>
|
290
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid_type?</span> <span class="ruby-identifier">value</span>
|
291
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span>, <span class="ruby-node">"atomTextConstruct type '#{value}' is meaningless"</span>
|
292
|
+
<span class="ruby-keyword kw">end</span>
|
293
|
+
|
294
|
+
<span class="ruby-ivar">@type</span> = <span class="ruby-identifier">value</span>
|
295
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"xhtml"</span>
|
296
|
+
<span class="ruby-keyword kw">begin</span>
|
297
|
+
<span class="ruby-identifier">parse_xhtml_content</span>
|
298
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseException</span>
|
299
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span>, <span class="ruby-node">"#{@content.inspect} can't be parsed as XML"</span>
|
300
|
+
<span class="ruby-keyword kw">end</span>
|
301
|
+
<span class="ruby-keyword kw">end</span>
|
302
|
+
<span class="ruby-keyword kw">end</span>
|
303
|
+
</pre>
|
304
|
+
</div>
|
305
|
+
</div>
|
306
|
+
</div>
|
307
|
+
|
308
|
+
<div id="method-M000055" class="method-detail">
|
309
|
+
<a name="M000055"></a>
|
310
|
+
|
311
|
+
<div class="method-heading">
|
312
|
+
<a href="#M000055" class="method-signature">
|
313
|
+
<span class="method-name">xml</span><span class="method-args">()</span>
|
314
|
+
</a>
|
315
|
+
</div>
|
316
|
+
|
317
|
+
<div class="method-description">
|
318
|
+
<p>
|
319
|
+
attempts to parse the content of this element as XML and return it as an
|
320
|
+
array of REXML::Elements.
|
321
|
+
</p>
|
322
|
+
<p>
|
323
|
+
If self["<a href="Text.html#M000052">type</a>"] is "<a
|
324
|
+
href="Text.html#M000054">html</a>" and Hpricot is installed, it will
|
325
|
+
be converted to <a href="../XHTML.html">XHTML</a> first.
|
326
|
+
</p>
|
327
|
+
<p><a class="source-toggle" href="#"
|
328
|
+
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
329
|
+
<div class="method-source-code" id="M000055-source">
|
330
|
+
<pre>
|
331
|
+
<span class="ruby-comment cmt"># File lib/atom/text.rb, line 115</span>
|
332
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">xml</span>
|
333
|
+
<span class="ruby-identifier">xml</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span> <span class="ruby-value str">'div'</span>
|
334
|
+
|
335
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"xhtml"</span>
|
336
|
+
<span class="ruby-ivar">@content</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">xml</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">child</span> }
|
337
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"text"</span>
|
338
|
+
<span class="ruby-identifier">xml</span>.<span class="ruby-identifier">text</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
|
339
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">"type"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"html"</span>
|
340
|
+
<span class="ruby-keyword kw">begin</span>
|
341
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">"hpricot"</span>
|
342
|
+
<span class="ruby-keyword kw">rescue</span>
|
343
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"Turning HTML content into XML requires Hpricot."</span>
|
344
|
+
<span class="ruby-keyword kw">end</span>
|
345
|
+
|
346
|
+
<span class="ruby-identifier">fixed</span> = <span class="ruby-constant">Hpricot</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">:xhtml_strict</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>)
|
347
|
+
<span class="ruby-identifier">xml</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"<div>#{fixed}</div>"</span>).<span class="ruby-identifier">root</span>
|
348
|
+
<span class="ruby-keyword kw">else</span>
|
349
|
+
<span class="ruby-comment cmt"># Not XHTML, HTML, or text - return the REXML::Element, leave it up to the user to parse the content</span>
|
350
|
+
<span class="ruby-identifier">xml</span> = <span class="ruby-ivar">@content</span>
|
351
|
+
<span class="ruby-keyword kw">end</span>
|
352
|
+
|
353
|
+
<span class="ruby-identifier">xml</span>
|
354
|
+
<span class="ruby-keyword kw">end</span>
|
355
|
+
</pre>
|
356
|
+
</div>
|
357
|
+
</div>
|
358
|
+
</div>
|
359
|
+
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
|
364
|
+
</div>
|
365
|
+
|
366
|
+
|
367
|
+
<div id="validator-badges">
|
368
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
369
|
+
</div>
|
370
|
+
|
371
|
+
</body>
|
372
|
+
</html>
|