fto 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.txt +20 -0
- data/NOTICE.txt +5 -0
- data/doc/classes/FormatText/Context.html +17 -8
- data/doc/classes/FormatText/Context.src/M000008.html +1 -1
- data/doc/classes/FormatText/Context.src/M000009.html +2 -2
- data/doc/classes/FormatText/Effector.html +73 -32
- data/doc/classes/FormatText/Effector.src/M000009.html +1 -1
- data/doc/classes/FormatText/Effector.src/M000010.html +29 -5
- data/doc/classes/FormatText/Effector.src/M000011.html +5 -4
- data/doc/classes/FormatText/Effector.src/M000012.html +4 -5
- data/doc/classes/FormatText/Effector.src/M000013.html +5 -4
- data/doc/classes/FormatText/Effector.src/M000014.html +1 -1
- data/doc/classes/FormatText/FTO.html +75 -38
- data/doc/classes/FormatText/FTO.src/M000001.html +2 -1
- data/doc/classes/FormatText/FTO.src/M000002.html +4 -18
- data/doc/classes/FormatText/FTO.src/M000003.html +18 -6
- data/doc/classes/FormatText/FTO.src/M000004.html +7 -4
- data/doc/classes/FormatText/FTO.src/M000005.html +5 -8
- data/doc/classes/FormatText/FTO.src/M000006.html +8 -6
- data/doc/classes/FormatText/FTO.src/M000007.html +6 -49
- data/doc/classes/FormatText/FTO.src/M000008.html +17 -9
- data/doc/created.rid +1 -1
- data/doc/files/lib/fto_rb.html +1 -1
- data/doc/fr_method_index.html +13 -12
- data/lib/fto.rb +385 -135
- data/test/test_fto_api.rb +43 -19
- data/test/test_fto_effectors.rb +25 -0
- metadata +4 -2
@@ -88,20 +88,20 @@ others are for developers modifying or extending the <tt>fto</tt> library.
|
|
88
88
|
<em><a href="FTO.html">FTO</a></em> is a subclass of <em>String</em>, so
|
89
89
|
all <em>String</em> methods work on an <em><a href="FTO.html">FTO</a></em>
|
90
90
|
object. <em><a href="FTO.html">FTO</a></em> provides the additional <em><a
|
91
|
-
href="FTO.html#
|
91
|
+
href="FTO.html#M000008">format</a>()</em> method.
|
92
92
|
</p>
|
93
93
|
<p>
|
94
94
|
In addition to string text, the constructor (<em><a
|
95
95
|
href="FTO.html#M000001">FTO.new</a></em>) can take more than a single
|
96
96
|
argument. Additional arguments will be stored as part of the object and
|
97
97
|
will be available to the <em><a
|
98
|
-
href="FTO.html#
|
98
|
+
href="FTO.html#M000008">FTO#format</a>()</em> method at runtime.
|
99
99
|
</p>
|
100
100
|
<p>
|
101
101
|
An <em><a href="FTO.html">FTO</a></em> object can be created as just a
|
102
102
|
formatting string, or the constructor invocation can also include values to
|
103
|
-
be applied by the <em><a href="FTO.html#
|
104
|
-
method. At runtime the <em><a href="FTO.html#
|
103
|
+
be applied by the <em><a href="FTO.html#M000008">FTO#format</a>()</em>
|
104
|
+
method. At runtime the <em><a href="FTO.html#M000008">format</a>()</em>
|
105
105
|
method can override any argument list provided at instantiation, but the
|
106
106
|
latter is not lost.
|
107
107
|
</p>
|
@@ -115,13 +115,14 @@ latter is not lost.
|
|
115
115
|
<h3 class="section-bar">Methods</h3>
|
116
116
|
|
117
117
|
<div class="name-list">
|
118
|
-
<a href="#
|
119
|
-
<a href="#M000005">
|
120
|
-
<a href="#
|
121
|
-
<a href="#
|
122
|
-
<a href="#M000007">
|
118
|
+
<a href="#M000002">clearEffectorList</a>
|
119
|
+
<a href="#M000005">destroyEffector</a>
|
120
|
+
<a href="#M000006">disableEffector</a>
|
121
|
+
<a href="#M000004">enableEffector</a>
|
122
|
+
<a href="#M000007">findEffectors</a>
|
123
|
+
<a href="#M000008">format</a>
|
123
124
|
<a href="#M000001">new</a>
|
124
|
-
<a href="#
|
125
|
+
<a href="#M000003">registerEffector</a>
|
125
126
|
</div>
|
126
127
|
</div>
|
127
128
|
|
@@ -136,6 +137,24 @@ latter is not lost.
|
|
136
137
|
|
137
138
|
|
138
139
|
|
140
|
+
<div id="attribute-list">
|
141
|
+
<h3 class="section-bar">Attributes</h3>
|
142
|
+
|
143
|
+
<div class="name-list">
|
144
|
+
<table>
|
145
|
+
<tr class="top-aligned-row context-row">
|
146
|
+
<td class="context-item-name">safe</td>
|
147
|
+
<td class="context-item-value"> [RW] </td>
|
148
|
+
<td class="context-item-desc">
|
149
|
+
Not yet implemented Controls whether the final string is built safely and
|
150
|
+
conservatively, or if the output of each effector can alter the input to
|
151
|
+
subsequent ones.
|
152
|
+
|
153
|
+
</td>
|
154
|
+
</tr>
|
155
|
+
</table>
|
156
|
+
</div>
|
157
|
+
</div>
|
139
158
|
|
140
159
|
|
141
160
|
|
@@ -143,22 +162,21 @@ latter is not lost.
|
|
143
162
|
<div id="methods">
|
144
163
|
<h3 class="section-bar">Public Class methods</h3>
|
145
164
|
|
146
|
-
<div id="method-
|
147
|
-
<a name="
|
165
|
+
<div id="method-M000002" class="method-detail">
|
166
|
+
<a name="M000002"></a>
|
148
167
|
|
149
168
|
<div class="method-heading">
|
150
|
-
<a href="FTO.src/
|
151
|
-
onclick="popupCode('FTO.src/
|
152
|
-
<span class="method-name">FTO.
|
169
|
+
<a href="FTO.src/M000002.html" target="Code" class="method-signature"
|
170
|
+
onclick="popupCode('FTO.src/M000002.html');return false;">
|
171
|
+
<span class="method-name">FTO.clearEffectorList<i>()</i> => <i>nil</i><br />
|
153
172
|
</span>
|
154
173
|
</a>
|
155
174
|
</div>
|
156
175
|
|
157
176
|
<div class="method-description">
|
158
177
|
<p>
|
159
|
-
|
160
|
-
|
161
|
-
REVERSIBLE!</strong>
|
178
|
+
Clear all effectors from the list (as a prelude to using a different
|
179
|
+
syntax, for instance).
|
162
180
|
</p>
|
163
181
|
</div>
|
164
182
|
</div>
|
@@ -169,6 +187,25 @@ REVERSIBLE!</strong>
|
|
169
187
|
<div class="method-heading">
|
170
188
|
<a href="FTO.src/M000005.html" target="Code" class="method-signature"
|
171
189
|
onclick="popupCode('FTO.src/M000005.html');return false;">
|
190
|
+
<span class="method-name">FTO.destroyEffector<i>(Fixnum)</i> => <i>nil</i><br />
|
191
|
+
</span>
|
192
|
+
</a>
|
193
|
+
</div>
|
194
|
+
|
195
|
+
<div class="method-description">
|
196
|
+
<p>
|
197
|
+
Completely removes the effector with the specified ID from the <a
|
198
|
+
href="FTO.html">FTO</a> system. <b>THIS IS NOT REVERSIBLE!</b>
|
199
|
+
</p>
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<div id="method-M000006" class="method-detail">
|
204
|
+
<a name="M000006"></a>
|
205
|
+
|
206
|
+
<div class="method-heading">
|
207
|
+
<a href="FTO.src/M000006.html" target="Code" class="method-signature"
|
208
|
+
onclick="popupCode('FTO.src/M000006.html');return false;">
|
172
209
|
<span class="method-name">FTO.disableEffector<i>(Fixnum)</i> => <i>nil</i><br />
|
173
210
|
</span>
|
174
211
|
</a>
|
@@ -177,18 +214,18 @@ REVERSIBLE!</strong>
|
|
177
214
|
<div class="method-description">
|
178
215
|
<p>
|
179
216
|
Disables the effector with the specified ID (such as from <em><a
|
180
|
-
href="FTO.html#
|
217
|
+
href="FTO.html#M000007">FTO.findEffectors</a>()</em>). This is a no-op if
|
181
218
|
the effector is already disabled.
|
182
219
|
</p>
|
183
220
|
</div>
|
184
221
|
</div>
|
185
222
|
|
186
|
-
<div id="method-
|
187
|
-
<a name="
|
223
|
+
<div id="method-M000004" class="method-detail">
|
224
|
+
<a name="M000004"></a>
|
188
225
|
|
189
226
|
<div class="method-heading">
|
190
|
-
<a href="FTO.src/
|
191
|
-
onclick="popupCode('FTO.src/
|
227
|
+
<a href="FTO.src/M000004.html" target="Code" class="method-signature"
|
228
|
+
onclick="popupCode('FTO.src/M000004.html');return false;">
|
192
229
|
<span class="method-name">FTO.enableEffector<i>(Fixnum)</i> => <i>nil</i><br />
|
193
230
|
</span>
|
194
231
|
</a>
|
@@ -202,12 +239,12 @@ Enables the effector with the specified ID (found in the effector‘s
|
|
202
239
|
</div>
|
203
240
|
</div>
|
204
241
|
|
205
|
-
<div id="method-
|
206
|
-
<a name="
|
242
|
+
<div id="method-M000007" class="method-detail">
|
243
|
+
<a name="M000007"></a>
|
207
244
|
|
208
245
|
<div class="method-heading">
|
209
|
-
<a href="FTO.src/
|
210
|
-
onclick="popupCode('FTO.src/
|
246
|
+
<a href="FTO.src/M000007.html" target="Code" class="method-signature"
|
247
|
+
onclick="popupCode('FTO.src/M000007.html');return false;">
|
211
248
|
<span class="method-name">FTO.findEffectors<i>(String)</i> => <i>Array</i><br />
|
212
249
|
FTO.findEffectors<i>(Regexp)</i> => <i>Array</i><br />
|
213
250
|
</span>
|
@@ -238,18 +275,18 @@ new<i>(String, arg [, ...])</i> => <i>FTO object</i><br />
|
|
238
275
|
<div class="method-description">
|
239
276
|
<p>
|
240
277
|
Any argument list is supplied at object instantiation can be temporarily
|
241
|
-
overridden when the <em><a href="FTO.html#
|
278
|
+
overridden when the <em><a href="FTO.html#M000008">FTO#format</a>()</em>
|
242
279
|
method is invoked.
|
243
280
|
</p>
|
244
281
|
</div>
|
245
282
|
</div>
|
246
283
|
|
247
|
-
<div id="method-
|
248
|
-
<a name="
|
284
|
+
<div id="method-M000003" class="method-detail">
|
285
|
+
<a name="M000003"></a>
|
249
286
|
|
250
287
|
<div class="method-heading">
|
251
|
-
<a href="FTO.src/
|
252
|
-
onclick="popupCode('FTO.src/
|
288
|
+
<a href="FTO.src/M000003.html" target="Code" class="method-signature"
|
289
|
+
onclick="popupCode('FTO.src/M000003.html');return false;">
|
253
290
|
<span class="method-name">FTO.registerEffector<i>(FormatText::Effector)</i> => <i>nil</i><br />
|
254
291
|
FTO.registerEffector<i>({ :symattr => value [, ...] })</i> => <i>nil</i><br />
|
255
292
|
</span>
|
@@ -259,19 +296,19 @@ FTO.registerEffector<i>({ :symattr => value [, ...] })</i> => <i>nil</i><br />
|
|
259
296
|
<div class="method-description">
|
260
297
|
<p>
|
261
298
|
Add an effector description to the list of those which will be processed by
|
262
|
-
the <em><a href="FTO.html#
|
299
|
+
the <em><a href="FTO.html#M000008">FTO#format</a>()</em> method.
|
263
300
|
</p>
|
264
301
|
</div>
|
265
302
|
</div>
|
266
303
|
|
267
304
|
<h3 class="section-bar">Public Instance methods</h3>
|
268
305
|
|
269
|
-
<div id="method-
|
270
|
-
<a name="
|
306
|
+
<div id="method-M000008" class="method-detail">
|
307
|
+
<a name="M000008"></a>
|
271
308
|
|
272
309
|
<div class="method-heading">
|
273
|
-
<a href="FTO.src/
|
274
|
-
onclick="popupCode('FTO.src/
|
310
|
+
<a href="FTO.src/M000008.html" target="Code" class="method-signature"
|
311
|
+
onclick="popupCode('FTO.src/M000008.html');return false;">
|
275
312
|
<span class="method-name">format<i>()</i> => <i>String</i><br />
|
276
313
|
format<i>(arg [, ...])</i> => <i>String</i><br />
|
277
314
|
format<i>(Array)</i> => <i>String</i><br />
|
@@ -283,7 +320,7 @@ format<i>(FormatText::Context)</i> => <i>String</i> (<u>internal use only</u>)<b
|
|
283
320
|
<div class="method-description">
|
284
321
|
<p>
|
285
322
|
Process the formatting string, optionally with a runtime argument list. The
|
286
|
-
argument list can either be a list of values, an array of values, or
|
323
|
+
argument list can either be a list of values, an array of values, or a
|
287
324
|
<em><a href="Context.html">FormatText::Context</a></em> object. (The latter
|
288
325
|
is intended only for internal use with recursion.)
|
289
326
|
</p>
|
@@ -10,9 +10,10 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 293</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">text</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
15
15
|
<span class="ruby-constant">String_initialize</span>(<span class="ruby-identifier">text</span>)
|
16
|
+
<span class="ruby-ivar">@safe</span> = <span class="ruby-keyword kw">true</span>
|
16
17
|
<span class="ruby-ivar">@args</span> = <span class="ruby-identifier">args</span>
|
17
18
|
<span class="ruby-keyword kw">end</span></pre>
|
18
19
|
</body>
|
@@ -5,28 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>clearEffectorList (FormatText::FTO)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
16
|
-
<span class="ruby-identifier">newE</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
|
17
|
-
<span class="ruby-keyword kw">else</span>
|
18
|
-
<span class="ruby-identifier">newE</span> = <span class="ruby-constant">Effector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'placeholder'</span>)
|
19
|
-
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&&</span> (<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Hash</span>))
|
20
|
-
<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
|
21
|
-
<span class="ruby-identifier">eval</span>(<span class="ruby-node">"newE.#{key.to_s} = val"</span>)
|
22
|
-
<span class="ruby-keyword kw">end</span>
|
23
|
-
<span class="ruby-keyword kw">else</span>
|
24
|
-
<span class="ruby-identifier">newE</span> = <span class="ruby-constant">Effector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>)
|
25
|
-
<span class="ruby-keyword kw">end</span>
|
26
|
-
<span class="ruby-keyword kw">end</span>
|
27
|
-
<span class="ruby-ivar">@@RegisteredEffectors</span>[<span class="ruby-identifier">newE</span>.<span class="ruby-identifier">id</span>] = <span class="ruby-identifier">newE</span>
|
28
|
-
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">'%06d-%s'</span>, <span class="ruby-identifier">newE</span>.<span class="ruby-identifier">priority</span>, <span class="ruby-identifier">newE</span>.<span class="ruby-identifier">name</span>)
|
29
|
-
<span class="ruby-identifier">newE</span>.<span class="ruby-identifier">sortKey</span> = <span class="ruby-identifier">key</span>
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 306</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">clearEffectorList</span>()
|
15
|
+
<span class="ruby-ivar">@@RegisteredEffectors</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>,<span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">true</span> }
|
30
16
|
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rebuildEffectorList</span>()
|
31
17
|
<span class="ruby-keyword kw">nil</span>
|
32
18
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -5,18 +5,30 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>registerEffector (FormatText::FTO)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">
|
15
|
-
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">
|
16
|
-
<span class="ruby-identifier">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 320</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">registerEffector</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
15
|
+
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&&</span> (<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/Effector$/</span>)))
|
16
|
+
<span class="ruby-identifier">newE</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
|
17
|
+
<span class="ruby-keyword kw">else</span>
|
18
|
+
<span class="ruby-identifier">newE</span> = <span class="ruby-constant">Effector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'placeholder'</span>)
|
19
|
+
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&&</span> (<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Hash</span>))
|
20
|
+
<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
|
21
|
+
<span class="ruby-identifier">eval</span>(<span class="ruby-node">"newE.#{key.to_s} = val"</span>)
|
22
|
+
<span class="ruby-keyword kw">end</span>
|
23
|
+
<span class="ruby-keyword kw">else</span>
|
24
|
+
<span class="ruby-identifier">newE</span> = <span class="ruby-constant">Effector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>)
|
25
|
+
<span class="ruby-keyword kw">end</span>
|
17
26
|
<span class="ruby-keyword kw">end</span>
|
18
|
-
<span class="ruby-identifier">
|
27
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">'%06d-%s'</span>, <span class="ruby-identifier">newE</span>.<span class="ruby-identifier">priority</span>, <span class="ruby-identifier">newE</span>.<span class="ruby-identifier">name</span>)
|
28
|
+
<span class="ruby-identifier">newE</span>.<span class="ruby-identifier">sortKey</span> = <span class="ruby-identifier">key</span>
|
29
|
+
<span class="ruby-ivar">@@RegisteredEffectors</span>[<span class="ruby-identifier">newE</span>.<span class="ruby-identifier">id</span>] = <span class="ruby-identifier">newE</span>
|
19
30
|
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rebuildEffectorList</span>()
|
31
|
+
<span class="ruby-keyword kw">nil</span>
|
20
32
|
<span class="ruby-keyword kw">end</span></pre>
|
21
33
|
</body>
|
22
34
|
</html>
|
@@ -5,14 +5,17 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>enableEffector (FormatText::FTO)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 369</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">enableEffector</span>(<span class="ruby-identifier">id</span>)
|
15
|
+
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@@RegisteredEffectors</span>[<span class="ruby-identifier">id</span>]).<span class="ruby-identifier">nil?</span>)
|
16
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">RuntimeError</span>, <span class="ruby-identifier">_</span>(<span class="ruby-value str">'No such effector '</span>) <span class="ruby-operator">+</span> <span class="ruby-node">"ID\##{id}"</span>
|
17
|
+
<span class="ruby-keyword kw">end</span>
|
18
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">true</span>
|
16
19
|
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rebuildEffectorList</span>()
|
17
20
|
<span class="ruby-keyword kw">end</span></pre>
|
18
21
|
</body>
|
@@ -5,18 +5,15 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>destroyEffector (FormatText::FTO)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
16
|
-
|
17
|
-
<span class="ruby-keyword kw">end</span>
|
18
|
-
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">disable</span>
|
19
|
-
<span class="ruby-keyword kw">nil</span>
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 384</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">destroyEffector</span>(<span class="ruby-identifier">id</span>)
|
15
|
+
<span class="ruby-ivar">@@RegisteredEffectors</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">id</span>)
|
16
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rebuildEffectorList</span>()
|
20
17
|
<span class="ruby-keyword kw">end</span></pre>
|
21
18
|
</body>
|
22
19
|
</html>
|
@@ -5,16 +5,18 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>disableEffector (FormatText::FTO)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">
|
15
|
-
<span class="ruby-
|
16
|
-
|
17
|
-
<span class="ruby-
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 397</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">disableEffector</span>(<span class="ruby-identifier">id</span>)
|
15
|
+
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@@RegisteredEffectors</span>[<span class="ruby-identifier">id</span>]).<span class="ruby-identifier">nil?</span>)
|
16
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">RuntimeError</span>, <span class="ruby-identifier">_</span>(<span class="ruby-value str">'No such effector '</span>) <span class="ruby-operator">+</span> <span class="ruby-node">"ID\##{id}"</span>
|
17
|
+
<span class="ruby-keyword kw">end</span>
|
18
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">disable</span>
|
19
|
+
<span class="ruby-keyword kw">nil</span>
|
18
20
|
<span class="ruby-keyword kw">end</span></pre>
|
19
21
|
</body>
|
20
22
|
</html>
|
@@ -5,59 +5,16 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>findEffectors (FormatText::FTO)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-
|
15
|
-
<span class="ruby-identifier">
|
16
|
-
<span class="ruby-
|
17
|
-
|
18
|
-
<span class="ruby-keyword kw">end</span>
|
19
|
-
<span class="ruby-comment cmt">#</span>
|
20
|
-
<span class="ruby-comment cmt"># It's possible we were passed a Context object so we can</span>
|
21
|
-
<span class="ruby-comment cmt"># recurse. If so, use its values for some of these.</span>
|
22
|
-
<span class="ruby-comment cmt">#</span>
|
23
|
-
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&&</span> (<span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">FormatText</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>))
|
24
|
-
<span class="ruby-identifier">eContext</span> = <span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>]
|
25
|
-
<span class="ruby-identifier">usedArgs</span> = <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">usedArgs</span>
|
26
|
-
<span class="ruby-identifier">argList</span> = <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">argList</span>
|
27
|
-
<span class="ruby-keyword kw">else</span>
|
28
|
-
<span class="ruby-identifier">usedArgs</span> = []
|
29
|
-
<span class="ruby-identifier">eContext</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>({
|
30
|
-
<span class="ruby-identifier">:ftoObj</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">self</span>,
|
31
|
-
<span class="ruby-identifier">:usedArgs</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">usedArgs</span>,
|
32
|
-
<span class="ruby-identifier">:argList</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">argList</span>
|
33
|
-
})
|
34
|
-
<span class="ruby-keyword kw">end</span>
|
35
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
|
36
|
-
<span class="ruby-identifier">effector</span> = <span class="ruby-identifier">sMatched</span> = <span class="ruby-keyword kw">nil</span>
|
37
|
-
<span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">m</span> = <span class="ruby-identifier">result</span>.<span class="ruby-identifier">match</span>(<span class="ruby-ivar">@@regex</span>))
|
38
|
-
<span class="ruby-comment cmt">#</span>
|
39
|
-
<span class="ruby-comment cmt"># Find out which effector was matched. The index in .captures</span>
|
40
|
-
<span class="ruby-comment cmt"># will be the same as the index in @effectors.</span>
|
41
|
-
<span class="ruby-comment cmt">#</span>
|
42
|
-
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
43
|
-
<span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">nil?</span>)
|
44
|
-
<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">effectorObj</span> = <span class="ruby-identifier">effector</span> = <span class="ruby-ivar">@@EnabledEffectors</span>[<span class="ruby-ivar">@@EffectorKeys</span>[<span class="ruby-identifier">i</span>]]
|
45
|
-
<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">sMatched</span> = <span class="ruby-identifier">sMatched</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-identifier">i</span>]
|
46
|
-
<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">reuseArg</span> = <span class="ruby-keyword kw">false</span>
|
47
|
-
<span class="ruby-keyword kw">break</span>
|
48
|
-
<span class="ruby-keyword kw">end</span>
|
49
|
-
<span class="ruby-comment cmt">#</span>
|
50
|
-
<span class="ruby-comment cmt"># Call the workhorse for this descriptor</span>
|
51
|
-
<span class="ruby-comment cmt">#</span>
|
52
|
-
<span class="ruby-identifier">replacement</span> = <span class="ruby-identifier">effector</span>.<span class="ruby-identifier">code</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">eContext</span>)
|
53
|
-
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-identifier">sMatched</span>, <span class="ruby-identifier">replacement</span>)
|
54
|
-
<span class="ruby-comment cmt">#</span>
|
55
|
-
<span class="ruby-comment cmt"># Mark the item at the front of the argument list as having</span>
|
56
|
-
<span class="ruby-comment cmt"># been used, if the effector agrees.</span>
|
57
|
-
<span class="ruby-comment cmt">#</span>
|
58
|
-
<span class="ruby-identifier">usedArgs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">shift</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">reuseArg</span>)
|
59
|
-
<span class="ruby-keyword kw">end</span>
|
60
|
-
<span class="ruby-identifier">result</span>
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 413</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">findEffectors</span>(<span class="ruby-identifier">pattern</span>)
|
15
|
+
<span class="ruby-identifier">pattern</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pattern</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Regexp</span>)
|
16
|
+
<span class="ruby-identifier">matches</span> = <span class="ruby-ivar">@@RegisteredEffectors</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>,<span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">pattern</span>) }
|
17
|
+
<span class="ruby-identifier">matches</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>,<span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> }
|
61
18
|
<span class="ruby-keyword kw">end</span></pre>
|
62
19
|
</body>
|
63
20
|
</html>
|
@@ -10,15 +10,15 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/fto.rb, line 432</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">format</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">argListp</span>)
|
15
15
|
<span class="ruby-identifier">argList</span> = <span class="ruby-identifier">argListp</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-ivar">@args</span>.<span class="ruby-identifier">clone</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">argListp</span>
|
16
16
|
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&&</span> (<span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>)) <span class="ruby-operator">&&</span>
|
17
17
|
<span class="ruby-identifier">argList</span> = <span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>]
|
18
18
|
<span class="ruby-keyword kw">end</span>
|
19
19
|
<span class="ruby-comment cmt">#</span>
|
20
|
-
<span class="ruby-comment cmt"># It's possible we were passed a Context object so we can
|
21
|
-
<span class="ruby-comment cmt"># If so, use its values for some of these.</span>
|
20
|
+
<span class="ruby-comment cmt"># It's possible we were passed a Context object so we can</span>
|
21
|
+
<span class="ruby-comment cmt"># recurse. If so, use its values for some of these.</span>
|
22
22
|
<span class="ruby-comment cmt">#</span>
|
23
23
|
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&&</span> (<span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">FormatText</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>))
|
24
24
|
<span class="ruby-identifier">eContext</span> = <span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>]
|
@@ -32,9 +32,10 @@
|
|
32
32
|
<span class="ruby-identifier">:argList</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">argList</span>
|
33
33
|
})
|
34
34
|
<span class="ruby-keyword kw">end</span>
|
35
|
-
<span class="ruby-identifier">
|
35
|
+
<span class="ruby-identifier">input</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
|
36
|
+
<span class="ruby-identifier">output</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">clone</span>
|
36
37
|
<span class="ruby-identifier">effector</span> = <span class="ruby-identifier">sMatched</span> = <span class="ruby-keyword kw">nil</span>
|
37
|
-
<span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">m</span> = <span class="ruby-identifier">
|
38
|
+
<span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">m</span> = <span class="ruby-identifier">input</span>.<span class="ruby-identifier">match</span>(<span class="ruby-ivar">@@regex</span>))
|
38
39
|
<span class="ruby-comment cmt">#</span>
|
39
40
|
<span class="ruby-comment cmt"># Find out which effector was matched. The index in .captures</span>
|
40
41
|
<span class="ruby-comment cmt"># will be the same as the index in @effectors.</span>
|
@@ -50,14 +51,21 @@
|
|
50
51
|
<span class="ruby-comment cmt"># Call the workhorse for this descriptor</span>
|
51
52
|
<span class="ruby-comment cmt">#</span>
|
52
53
|
<span class="ruby-identifier">replacement</span> = <span class="ruby-identifier">effector</span>.<span class="ruby-identifier">code</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">eContext</span>)
|
53
|
-
<span class="ruby-identifier">
|
54
|
+
<span class="ruby-identifier">output</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-identifier">sMatched</span>, <span class="ruby-identifier">replacement</span>)
|
55
|
+
<span class="ruby-identifier">input</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-identifier">sMatched</span>, <span class="ruby-value str">''</span>)
|
54
56
|
<span class="ruby-comment cmt">#</span>
|
55
57
|
<span class="ruby-comment cmt"># Mark the item at the front of the argument list as having</span>
|
56
|
-
<span class="ruby-comment cmt"># been used, if the effector agrees
|
58
|
+
<span class="ruby-comment cmt"># been used, if the effector agrees. Assume that an argument</span>
|
59
|
+
<span class="ruby-comment cmt"># was actually used if we're moving it, and that the 'last</span>
|
60
|
+
<span class="ruby-comment cmt"># argument used' hasn't changed if the effector has set</span>
|
61
|
+
<span class="ruby-comment cmt"># _reuseArg_.</span>
|
57
62
|
<span class="ruby-comment cmt">#</span>
|
58
|
-
<span class="ruby-
|
63
|
+
<span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">reuseArg</span>)
|
64
|
+
<span class="ruby-identifier">usedArgs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">shift</span>)
|
65
|
+
<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">lastArgUsed</span> = <span class="ruby-identifier">usedArgs</span>.<span class="ruby-identifier">last</span>
|
66
|
+
<span class="ruby-keyword kw">end</span>
|
59
67
|
<span class="ruby-keyword kw">end</span>
|
60
|
-
<span class="ruby-identifier">
|
68
|
+
<span class="ruby-identifier">output</span>
|
61
69
|
<span class="ruby-keyword kw">end</span></pre>
|
62
70
|
</body>
|
63
71
|
</html>
|