rrtf 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -7
- data/documentation/RRTF/CharacterFormatting.html +1002 -0
- data/documentation/RRTF/CharacterStyle.html +1058 -0
- data/documentation/RRTF/Colour.html +813 -0
- data/documentation/RRTF/ColourTable.html +770 -0
- data/documentation/RRTF/CommandNode.html +2372 -0
- data/documentation/RRTF/ContainerNode.html +826 -0
- data/documentation/RRTF/Converters/HTML/Helpers.html +272 -0
- data/documentation/RRTF/Converters/HTML/Node.html +364 -0
- data/documentation/RRTF/Converters/HTML/NodeSet.html +265 -0
- data/documentation/RRTF/Converters/HTML.html +337 -0
- data/documentation/RRTF/Converters.html +117 -0
- data/documentation/RRTF/Document.html +2405 -0
- data/documentation/RRTF/DocumentStyle.html +1367 -0
- data/documentation/RRTF/Font.html +790 -0
- data/documentation/RRTF/FontTable.html +763 -0
- data/documentation/RRTF/FooterNode.html +515 -0
- data/documentation/RRTF/HeaderNode.html +515 -0
- data/documentation/RRTF/ImageNode.html +1374 -0
- data/documentation/RRTF/Information.html +809 -0
- data/documentation/RRTF/LinkNode.html +264 -0
- data/documentation/RRTF/ListLevel.html +799 -0
- data/documentation/RRTF/ListLevelNode.html +612 -0
- data/documentation/RRTF/ListMarker.html +595 -0
- data/documentation/RRTF/ListNode.html +368 -0
- data/documentation/RRTF/ListTable.html +343 -0
- data/documentation/RRTF/ListTemplate.html +433 -0
- data/documentation/RRTF/ListTextNode.html +285 -0
- data/documentation/RRTF/Node.html +616 -0
- data/documentation/RRTF/Paper.html +624 -0
- data/documentation/RRTF/ParagraphFormatting.html +749 -0
- data/documentation/RRTF/ParagraphNode.html +275 -0
- data/documentation/RRTF/ParagraphStyle.html +1319 -0
- data/documentation/RRTF/RTFError.html +295 -0
- data/documentation/RRTF/Style.html +1767 -0
- data/documentation/RRTF/Stylesheet.html +1768 -0
- data/documentation/RRTF/TableCellNode.html +1704 -0
- data/documentation/RRTF/TableNode.html +1025 -0
- data/documentation/RRTF/TableRowNode.html +675 -0
- data/documentation/RRTF/TextNode.html +600 -0
- data/documentation/RRTF/Utilities.html +201 -0
- data/documentation/RRTF.html +129 -0
- data/documentation/_index.html +478 -0
- data/documentation/class_list.html +51 -0
- data/documentation/css/common.css +1 -0
- data/documentation/css/full_list.css +58 -0
- data/documentation/css/style.css +492 -0
- data/documentation/file.README.html +223 -0
- data/documentation/file_list.html +56 -0
- data/documentation/frames.html +17 -0
- data/documentation/index.html +223 -0
- data/documentation/js/app.js +248 -0
- data/documentation/js/full_list.js +216 -0
- data/documentation/js/jquery.js +4 -0
- data/documentation/method_list.html +2203 -0
- data/documentation/top-level-namespace.html +110 -0
- data/examples/01.rtf +14 -17
- data/examples/01_mac_word15_36.png +0 -0
- data/examples/01_styles_and_paragraphs.rb +3 -4
- data/examples/resources/json/redshirt_styles.json +4 -2
- data/lib/rrtf/node.rb +86 -167
- data/lib/rrtf/style/character_style.rb +4 -3
- data/lib/rrtf/style/formatting.rb +55 -11
- data/lib/rrtf/style/paragraph_style.rb +19 -4
- data/lib/rrtf/style/style.rb +15 -15
- data/lib/rrtf/stylesheet.rb +57 -16
- data/lib/rrtf/version.rb +1 -1
- data/rrtf.gemspec +1 -0
- metadata +70 -1
@@ -0,0 +1,600 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: RRTF::TextNode
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "RRTF::TextNode";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (T)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../RRTF.html" title="RRTF (module)">RRTF</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">TextNode</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: RRTF::TextNode
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="Node.html" title="RRTF::Node (class)">Node</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="Node.html" title="RRTF::Node (class)">Node</a></span></li>
|
78
|
+
|
79
|
+
<li class="next">RRTF::TextNode</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/rrtf/node.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
|
107
|
+
<p>This class represents a specialisation of the Node class to refer to a Node
|
108
|
+
that simply contains text.</p>
|
109
|
+
|
110
|
+
|
111
|
+
</div>
|
112
|
+
</div>
|
113
|
+
<div class="tags">
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
121
|
+
<ul class="summary">
|
122
|
+
|
123
|
+
<li class="public ">
|
124
|
+
<span class="summary_signature">
|
125
|
+
|
126
|
+
<a href="#text-instance_method" title="#text (instance method)">#<strong>text</strong> ⇒ Object </a>
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
</span>
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<span class="summary_desc"><div class='inline'>
|
144
|
+
<p>Actual text.</p>
|
145
|
+
</div></span>
|
146
|
+
|
147
|
+
</li>
|
148
|
+
|
149
|
+
|
150
|
+
</ul>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
<h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Node.html" title="RRTF::Node (class)">Node</a></span></h3>
|
157
|
+
<p class="inherited"><span class='object_link'><a href="Node.html#parent-instance_method" title="RRTF::Node#parent (method)">#parent</a></span></p>
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<h2>
|
162
|
+
Instance Method Summary
|
163
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
164
|
+
</h2>
|
165
|
+
|
166
|
+
<ul class="summary">
|
167
|
+
|
168
|
+
<li class="public ">
|
169
|
+
<span class="summary_signature">
|
170
|
+
|
171
|
+
<a href="#append-instance_method" title="#append (instance method)">#<strong>append</strong>(text) ⇒ Object </a>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
</span>
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<span class="summary_desc"><div class='inline'>
|
186
|
+
<p>This method concatenates a String on to the end of the existing text within
|
187
|
+
a TextNode object.</p>
|
188
|
+
</div></span>
|
189
|
+
|
190
|
+
</li>
|
191
|
+
|
192
|
+
|
193
|
+
<li class="public ">
|
194
|
+
<span class="summary_signature">
|
195
|
+
|
196
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(parent, text = nil) ⇒ TextNode </a>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
</span>
|
201
|
+
|
202
|
+
|
203
|
+
<span class="note title constructor">constructor</span>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
<span class="summary_desc"><div class='inline'>
|
213
|
+
<p>This is the constructor for the TextNode class.</p>
|
214
|
+
</div></span>
|
215
|
+
|
216
|
+
</li>
|
217
|
+
|
218
|
+
|
219
|
+
<li class="public ">
|
220
|
+
<span class="summary_signature">
|
221
|
+
|
222
|
+
<a href="#insert-instance_method" title="#insert (instance method)">#<strong>insert</strong>(text, offset) ⇒ Object </a>
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
</span>
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
<span class="summary_desc"><div class='inline'>
|
237
|
+
<p>This method inserts a String into the existing text within a TextNode
|
238
|
+
object.</p>
|
239
|
+
</div></span>
|
240
|
+
|
241
|
+
</li>
|
242
|
+
|
243
|
+
|
244
|
+
<li class="public ">
|
245
|
+
<span class="summary_signature">
|
246
|
+
|
247
|
+
<a href="#to_rtf-instance_method" title="#to_rtf (instance method)">#<strong>to_rtf</strong> ⇒ Object </a>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
</span>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
<span class="summary_desc"><div class='inline'>
|
262
|
+
<p>This method generates the RTF equivalent for a TextNode object.</p>
|
263
|
+
</div></span>
|
264
|
+
|
265
|
+
</li>
|
266
|
+
|
267
|
+
|
268
|
+
</ul>
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="Node.html" title="RRTF::Node (class)">Node</a></span></h3>
|
281
|
+
<p class="inherited"><span class='object_link'><a href="Node.html#is_root%3F-instance_method" title="RRTF::Node#is_root? (method)">#is_root?</a></span>, <span class='object_link'><a href="Node.html#next_node-instance_method" title="RRTF::Node#next_node (method)">#next_node</a></span>, <span class='object_link'><a href="Node.html#previous_node-instance_method" title="RRTF::Node#previous_node (method)">#previous_node</a></span>, <span class='object_link'><a href="Node.html#root-instance_method" title="RRTF::Node#root (method)">#root</a></span></p>
|
282
|
+
<div id="constructor_details" class="method_details_list">
|
283
|
+
<h2>Constructor Details</h2>
|
284
|
+
|
285
|
+
<div class="method_details first">
|
286
|
+
<h3 class="signature first" id="initialize-instance_method">
|
287
|
+
|
288
|
+
#<strong>initialize</strong>(parent, text = nil) ⇒ <tt><span class='object_link'><a href="" title="RRTF::TextNode (class)">TextNode</a></span></tt>
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
</h3><div class="docstring">
|
295
|
+
<div class="discussion">
|
296
|
+
|
297
|
+
<p>This is the constructor for the TextNode class.</p>
|
298
|
+
|
299
|
+
<h4 id="label-Parameters">Parameters</h4>
|
300
|
+
<dl class="rdoc-list note-list"><dt>parent
|
301
|
+
<dd>
|
302
|
+
<p>A reference to the Node that owns the TextNode. Must not be nil.</p>
|
303
|
+
</dd><dt>text
|
304
|
+
<dd>
|
305
|
+
<p>A String containing the node text. Defaults to nil.</p>
|
306
|
+
</dd></dl>
|
307
|
+
|
308
|
+
<h4 id="label-Exceptions">Exceptions</h4>
|
309
|
+
<dl class="rdoc-list note-list"><dt>RTFError
|
310
|
+
<dd>
|
311
|
+
<p>Generated whenever an nil parent object is specified to the method.</p>
|
312
|
+
</dd></dl>
|
313
|
+
|
314
|
+
|
315
|
+
</div>
|
316
|
+
</div>
|
317
|
+
<div class="tags">
|
318
|
+
|
319
|
+
|
320
|
+
</div><table class="source_code">
|
321
|
+
<tr>
|
322
|
+
<td>
|
323
|
+
<pre class="lines">
|
324
|
+
|
325
|
+
|
326
|
+
73
|
327
|
+
74
|
328
|
+
75
|
329
|
+
76
|
330
|
+
77
|
331
|
+
78
|
332
|
+
79
|
333
|
+
80</pre>
|
334
|
+
</td>
|
335
|
+
<td>
|
336
|
+
<pre class="code"><span class="info file"># File 'lib/rrtf/node.rb', line 73</span>
|
337
|
+
|
338
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='id identifier rubyid_text'>text</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
339
|
+
<span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='rparen'>)</span>
|
340
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
341
|
+
<span class='const'><span class='object_link'><a href="RTFError.html" title="RRTF::RTFError (class)">RTFError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_fire'><span class='object_link'><a href="RTFError.html#fire-class_method" title="RRTF::RTFError.fire (method)">fire</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Nil parent specified for text node.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
342
|
+
<span class='kw'>end</span>
|
343
|
+
<span class='ivar'>@parent</span> <span class='op'>=</span> <span class='id identifier rubyid_parent'>parent</span>
|
344
|
+
<span class='ivar'>@text</span> <span class='op'>=</span> <span class='id identifier rubyid_text'>text</span>
|
345
|
+
<span class='kw'>end</span></pre>
|
346
|
+
</td>
|
347
|
+
</tr>
|
348
|
+
</table>
|
349
|
+
</div>
|
350
|
+
|
351
|
+
</div>
|
352
|
+
|
353
|
+
<div id="instance_attr_details" class="attr_details">
|
354
|
+
<h2>Instance Attribute Details</h2>
|
355
|
+
|
356
|
+
|
357
|
+
<span id="text=-instance_method"></span>
|
358
|
+
<div class="method_details first">
|
359
|
+
<h3 class="signature first" id="text-instance_method">
|
360
|
+
|
361
|
+
#<strong>text</strong> ⇒ <tt>Object</tt>
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
</h3><div class="docstring">
|
368
|
+
<div class="discussion">
|
369
|
+
|
370
|
+
<p>Actual text</p>
|
371
|
+
|
372
|
+
|
373
|
+
</div>
|
374
|
+
</div>
|
375
|
+
<div class="tags">
|
376
|
+
|
377
|
+
|
378
|
+
</div><table class="source_code">
|
379
|
+
<tr>
|
380
|
+
<td>
|
381
|
+
<pre class="lines">
|
382
|
+
|
383
|
+
|
384
|
+
61
|
385
|
+
62
|
386
|
+
63</pre>
|
387
|
+
</td>
|
388
|
+
<td>
|
389
|
+
<pre class="code"><span class="info file"># File 'lib/rrtf/node.rb', line 61</span>
|
390
|
+
|
391
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_text'>text</span>
|
392
|
+
<span class='ivar'>@text</span>
|
393
|
+
<span class='kw'>end</span></pre>
|
394
|
+
</td>
|
395
|
+
</tr>
|
396
|
+
</table>
|
397
|
+
</div>
|
398
|
+
|
399
|
+
</div>
|
400
|
+
|
401
|
+
|
402
|
+
<div id="instance_method_details" class="method_details_list">
|
403
|
+
<h2>Instance Method Details</h2>
|
404
|
+
|
405
|
+
|
406
|
+
<div class="method_details first">
|
407
|
+
<h3 class="signature first" id="append-instance_method">
|
408
|
+
|
409
|
+
#<strong>append</strong>(text) ⇒ <tt>Object</tt>
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
</h3><div class="docstring">
|
416
|
+
<div class="discussion">
|
417
|
+
|
418
|
+
<p>This method concatenates a String on to the end of the existing text within
|
419
|
+
a TextNode object.</p>
|
420
|
+
|
421
|
+
<h4 id="label-Parameters">Parameters</h4>
|
422
|
+
<dl class="rdoc-list note-list"><dt>text
|
423
|
+
<dd>
|
424
|
+
<p>The String to be added to the end of the text node.</p>
|
425
|
+
</dd></dl>
|
426
|
+
|
427
|
+
|
428
|
+
</div>
|
429
|
+
</div>
|
430
|
+
<div class="tags">
|
431
|
+
|
432
|
+
|
433
|
+
</div><table class="source_code">
|
434
|
+
<tr>
|
435
|
+
<td>
|
436
|
+
<pre class="lines">
|
437
|
+
|
438
|
+
|
439
|
+
87
|
440
|
+
88
|
441
|
+
89</pre>
|
442
|
+
</td>
|
443
|
+
<td>
|
444
|
+
<pre class="code"><span class="info file"># File 'lib/rrtf/node.rb', line 87</span>
|
445
|
+
|
446
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_append'>append</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='rparen'>)</span>
|
447
|
+
<span class='ivar'>@text</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='ivar'>@text</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>:</span> <span class='ivar'>@text</span> <span class='op'>+</span> <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
448
|
+
<span class='kw'>end</span></pre>
|
449
|
+
</td>
|
450
|
+
</tr>
|
451
|
+
</table>
|
452
|
+
</div>
|
453
|
+
|
454
|
+
<div class="method_details ">
|
455
|
+
<h3 class="signature " id="insert-instance_method">
|
456
|
+
|
457
|
+
#<strong>insert</strong>(text, offset) ⇒ <tt>Object</tt>
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
</h3><div class="docstring">
|
464
|
+
<div class="discussion">
|
465
|
+
|
466
|
+
<p>This method inserts a String into the existing text within a TextNode
|
467
|
+
object. If the TextNode contains no text then it is simply set to the text
|
468
|
+
passed in. If the offset specified is past the end of the nodes text then
|
469
|
+
it is simply appended to the end.</p>
|
470
|
+
|
471
|
+
<h4 id="label-Parameters">Parameters</h4>
|
472
|
+
<dl class="rdoc-list note-list"><dt>text
|
473
|
+
<dd>
|
474
|
+
<p>A String containing the text to be added.</p>
|
475
|
+
</dd><dt>offset
|
476
|
+
<dd>
|
477
|
+
<p>The numbers of characters from the first character to insert the new text
|
478
|
+
at.</p>
|
479
|
+
</dd></dl>
|
480
|
+
|
481
|
+
|
482
|
+
</div>
|
483
|
+
</div>
|
484
|
+
<div class="tags">
|
485
|
+
|
486
|
+
|
487
|
+
</div><table class="source_code">
|
488
|
+
<tr>
|
489
|
+
<td>
|
490
|
+
<pre class="lines">
|
491
|
+
|
492
|
+
|
493
|
+
100
|
494
|
+
101
|
495
|
+
102
|
496
|
+
103
|
497
|
+
104
|
498
|
+
105
|
499
|
+
106</pre>
|
500
|
+
</td>
|
501
|
+
<td>
|
502
|
+
<pre class="code"><span class="info file"># File 'lib/rrtf/node.rb', line 100</span>
|
503
|
+
|
504
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_insert'>insert</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='id identifier rubyid_offset'>offset</span><span class='rparen'>)</span>
|
505
|
+
<span class='kw'>if</span> <span class='op'>!</span><span class='ivar'>@text</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
506
|
+
<span class='ivar'>@text</span> <span class='op'>=</span> <span class='ivar'>@text</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_offset'>offset</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>+</span> <span class='ivar'>@text</span><span class='lbracket'>[</span><span class='id identifier rubyid_offset'>offset</span><span class='comma'>,</span> <span class='ivar'>@text</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rbracket'>]</span>
|
507
|
+
<span class='kw'>else</span>
|
508
|
+
<span class='ivar'>@text</span> <span class='op'>=</span> <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
509
|
+
<span class='kw'>end</span>
|
510
|
+
<span class='kw'>end</span></pre>
|
511
|
+
</td>
|
512
|
+
</tr>
|
513
|
+
</table>
|
514
|
+
</div>
|
515
|
+
|
516
|
+
<div class="method_details ">
|
517
|
+
<h3 class="signature " id="to_rtf-instance_method">
|
518
|
+
|
519
|
+
#<strong>to_rtf</strong> ⇒ <tt>Object</tt>
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
</h3><div class="docstring">
|
526
|
+
<div class="discussion">
|
527
|
+
|
528
|
+
<p>This method generates the RTF equivalent for a TextNode object. This method
|
529
|
+
escapes any special sequences that appear in the text.</p>
|
530
|
+
|
531
|
+
|
532
|
+
</div>
|
533
|
+
</div>
|
534
|
+
<div class="tags">
|
535
|
+
|
536
|
+
|
537
|
+
</div><table class="source_code">
|
538
|
+
<tr>
|
539
|
+
<td>
|
540
|
+
<pre class="lines">
|
541
|
+
|
542
|
+
|
543
|
+
110
|
544
|
+
111
|
545
|
+
112
|
546
|
+
113
|
547
|
+
114
|
548
|
+
115
|
549
|
+
116
|
550
|
+
117
|
551
|
+
118
|
552
|
+
119
|
553
|
+
120
|
554
|
+
121
|
555
|
+
122
|
556
|
+
123
|
557
|
+
124
|
558
|
+
125
|
559
|
+
126
|
560
|
+
127</pre>
|
561
|
+
</td>
|
562
|
+
<td>
|
563
|
+
<pre class="code"><span class="info file"># File 'lib/rrtf/node.rb', line 110</span>
|
564
|
+
|
565
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_rtf'>to_rtf</span>
|
566
|
+
<span class='id identifier rubyid_rtf'>rtf</span><span class='op'>=</span><span class='lparen'>(</span><span class='ivar'>@text</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span> <span class='op'>:</span> <span class='ivar'>@text</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>{</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\{</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\\\</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
|
567
|
+
<span class='comment'># This is from lfarcy / rtf-extensions
|
568
|
+
</span> <span class='comment'># I don't see the point of coding different 128<n<256 range
|
569
|
+
</span>
|
570
|
+
<span class='comment'>#f1=lambda { |n| n < 128 ? n.chr : n < 256 ? "\\'#{n.to_s(16)}" : "\\u#{n}\\'3f" }
|
571
|
+
</span> <span class='comment'># Encode as Unicode.
|
572
|
+
</span>
|
573
|
+
<span class='id identifier rubyid_f'>f</span><span class='op'>=</span><span class='id identifier rubyid_lambda'>lambda</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_n'>n</span> <span class='op'><</span> <span class='int'>128</span> <span class='op'>?</span> <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_chr'>chr</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\\u</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_n'>n</span><span class='embexpr_end'>}</span><span class='tstring_content'>\\'3f</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
574
|
+
<span class='comment'># Ruby 1.9 is safe, cause detect original encoding
|
575
|
+
</span> <span class='comment'># and convert text to utf-16 first
|
576
|
+
</span> <span class='kw'>if</span> <span class='const'>RUBY_VERSION</span><span class='op'>></span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1.9.0</span><span class='tstring_end'>"</span></span>
|
577
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_rtf'>rtf</span><span class='period'>.</span><span class='id identifier rubyid_encode'>encode</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>UTF-16LE</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:undef</span><span class='op'>=></span><span class='symbol'>:replace</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each_codepoint'>each_codepoint</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_f'>f</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
578
|
+
<span class='kw'>else</span>
|
579
|
+
<span class='comment'># You SHOULD use UTF-8 as input, ok?
|
580
|
+
</span> <span class='kw'>return</span> <span class='id identifier rubyid_rtf'>rtf</span><span class='period'>.</span><span class='id identifier rubyid_unpack'>unpack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>U*</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_f'>f</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
581
|
+
<span class='kw'>end</span>
|
582
|
+
<span class='kw'>end</span></pre>
|
583
|
+
</td>
|
584
|
+
</tr>
|
585
|
+
</table>
|
586
|
+
</div>
|
587
|
+
|
588
|
+
</div>
|
589
|
+
|
590
|
+
</div>
|
591
|
+
|
592
|
+
<div id="footer">
|
593
|
+
Generated on Mon Jul 24 15:48:59 2017 by
|
594
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
595
|
+
0.9.9 (ruby-2.3.3).
|
596
|
+
</div>
|
597
|
+
|
598
|
+
</div>
|
599
|
+
</body>
|
600
|
+
</html>
|