ionian 0.6.3 → 0.6.4
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 +63 -0
- data/doc/Ionian/Extension/IO.html +1062 -599
- data/doc/Ionian/Extension/Socket.html +2140 -1314
- data/doc/Ionian/Extension.html +98 -70
- data/doc/Ionian/Server.html +577 -345
- data/doc/Ionian/Socket.html +1100 -612
- data/doc/Ionian.html +100 -70
- data/doc/_index.html +164 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.README.html +133 -0
- data/doc/file.license.html +73 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +111 -71
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -18
- data/doc/method_list.html +419 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/ionian/extension/io.rb +4 -2
- data/lib/ionian/socket.rb +1 -1
- data/license.txt +2 -0
- metadata +28 -54
- data/doc/created.rid +0 -6
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/fonts.css +0 -167
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/js/darkfish.js +0 -140
- data/doc/js/navigation.js +0 -142
- data/doc/js/search.js +0 -109
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/rdoc.css +0 -580
- data/doc/table_of_contents.html +0 -402
@@ -1,463 +1,837 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: Ionian::Extension::IO
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.3
|
10
|
+
|
11
|
+
</title>
|
6
12
|
|
7
|
-
<
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
8
14
|
|
9
|
-
<link href="../../
|
10
|
-
<link href="../../rdoc.css" rel="stylesheet">
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
11
16
|
|
12
|
-
<script type="text/javascript">
|
13
|
-
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../../';
|
20
|
+
framesUrl = "../../frames.html#!" + escape(window.location.href);
|
14
21
|
</script>
|
15
22
|
|
16
|
-
|
17
|
-
<script src="../../js/
|
18
|
-
|
19
|
-
<script src="../../js/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<
|
25
|
-
<
|
26
|
-
|
27
|
-
<
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
<a href="../../table_of_contents.html#classes">Classes</a>
|
35
|
-
<a href="../../table_of_contents.html#methods">Methods</a>
|
36
|
-
</div>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (I)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Ionian.html" title="Ionian (module)">Ionian</a></span></span> » <span class='title'><span class='object_link'><a href="../Extension.html" title="Ionian::Extension (module)">Extension</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">IO</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
37
41
|
</div>
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
<
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
46
62
|
</div>
|
47
63
|
|
48
|
-
<
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Module: Ionian::Extension::IO
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<dt class="r1 last">Defined in:</dt>
|
82
|
+
<dd class="r1 last">lib/ionian/extension/io.rb</dd>
|
83
|
+
|
84
|
+
</dl>
|
85
|
+
<div class="clear"></div>
|
86
|
+
|
87
|
+
<h2>Overview</h2><div class="docstring">
|
88
|
+
<div class="discussion">
|
89
|
+
|
90
|
+
<p>A mixin for IO objects that allows regular expression matching and
|
91
|
+
convenient notification of received data.</p>
|
92
|
+
|
93
|
+
<p>This module was designed to be extended by instantiated objects that
|
94
|
+
implement the standard library IO class. my_socket.extend Ionian::IO</p>
|
95
|
+
|
53
96
|
|
54
97
|
</div>
|
98
|
+
</div>
|
99
|
+
<div class="tags">
|
100
|
+
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
107
|
+
<ul class="summary">
|
108
|
+
|
109
|
+
<li class="public ">
|
110
|
+
<span class="summary_signature">
|
111
|
+
|
112
|
+
<a href="#ionian_timeout-instance_method" title="#ionian_timeout (instance method)">- (Object) <strong>ionian_timeout</strong> </a>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
</span>
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<span class="summary_desc"><div class='inline'>
|
130
|
+
<p>Number of seconds to attempt an IO operation before timing out.</p>
|
131
|
+
</div></span>
|
132
|
+
|
133
|
+
</li>
|
134
|
+
|
135
|
+
|
136
|
+
</ul>
|
137
|
+
|
138
|
+
|
139
|
+
|
55
140
|
|
56
141
|
|
142
|
+
<h2>
|
143
|
+
Class Method Summary
|
144
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
145
|
+
</h2>
|
57
146
|
|
58
|
-
|
147
|
+
<ul class="summary">
|
148
|
+
|
149
|
+
<li class="public ">
|
150
|
+
<span class="summary_signature">
|
59
151
|
|
152
|
+
<a href="#extended-class_method" title="extended (class method)">+ (Object) <strong>extended</strong>(obj) </a>
|
60
153
|
|
154
|
+
|
155
|
+
|
156
|
+
</span>
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
<span class="summary_desc"><div class='inline'>
|
167
|
+
<p>Called automaticallly when the object is extended with #extend.</p>
|
168
|
+
</div></span>
|
169
|
+
|
170
|
+
</li>
|
171
|
+
|
172
|
+
|
173
|
+
</ul>
|
174
|
+
|
175
|
+
<h2>
|
176
|
+
Instance Method Summary
|
177
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
178
|
+
</h2>
|
179
|
+
|
180
|
+
<ul class="summary">
|
181
|
+
|
182
|
+
<li class="public ">
|
183
|
+
<span class="summary_signature">
|
61
184
|
|
185
|
+
<a href="#expression-instance_method" title="#expression (instance method)">- (Object) <strong>expression</strong> </a>
|
62
186
|
|
63
|
-
<!-- Method Quickref -->
|
64
|
-
<div id="method-list-section" class="nav-section">
|
65
|
-
<h3>Methods</h3>
|
66
187
|
|
67
|
-
<ul class="link-list" role="directory">
|
68
188
|
|
69
|
-
|
189
|
+
</span>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<span class="summary_desc"><div class='inline'>
|
200
|
+
<p>Returns the regular expression used for #read_match.</p>
|
201
|
+
</div></span>
|
202
|
+
|
203
|
+
</li>
|
204
|
+
|
205
|
+
|
206
|
+
<li class="public ">
|
207
|
+
<span class="summary_signature">
|
70
208
|
|
71
|
-
|
209
|
+
<a href="#expression%3D-instance_method" title="#expression= (instance method)">- (Object) <strong>expression=</strong>(exp) </a>
|
72
210
|
|
73
|
-
|
211
|
+
|
74
212
|
|
75
|
-
|
213
|
+
</span>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<span class="summary_desc"><div class='inline'>
|
224
|
+
<p>Set the expression to match against the read buffer.</p>
|
225
|
+
</div></span>
|
226
|
+
|
227
|
+
</li>
|
228
|
+
|
229
|
+
|
230
|
+
<li class="public ">
|
231
|
+
<span class="summary_signature">
|
76
232
|
|
77
|
-
|
233
|
+
<a href="#has_data%3F-instance_method" title="#has_data? (instance method)">- (Boolean) <strong>has_data?</strong>(timeout: 0) </a>
|
78
234
|
|
79
|
-
|
235
|
+
|
80
236
|
|
81
|
-
|
237
|
+
</span>
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<span class="summary_desc"><div class='inline'>
|
248
|
+
<p>Returns true if there is data in the receive buffer.</p>
|
249
|
+
</div></span>
|
250
|
+
|
251
|
+
</li>
|
252
|
+
|
253
|
+
|
254
|
+
<li class="public ">
|
255
|
+
<span class="summary_signature">
|
82
256
|
|
83
|
-
|
257
|
+
<a href="#initialize_ionian-instance_method" title="#initialize_ionian (instance method)">- (Object) <strong>initialize_ionian</strong> </a>
|
84
258
|
|
85
|
-
|
259
|
+
|
86
260
|
|
87
|
-
|
261
|
+
</span>
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
<span class="summary_desc"><div class='inline'>
|
272
|
+
<p>Initialize the Ionian instance variables.</p>
|
273
|
+
</div></span>
|
274
|
+
|
275
|
+
</li>
|
276
|
+
|
277
|
+
|
278
|
+
<li class="public ">
|
279
|
+
<span class="summary_signature">
|
88
280
|
|
89
|
-
|
281
|
+
<a href="#purge-instance_method" title="#purge (instance method)">- (Object) <strong>purge</strong> </a>
|
90
282
|
|
91
|
-
|
283
|
+
|
92
284
|
|
93
|
-
</
|
94
|
-
|
285
|
+
</span>
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
95
293
|
|
96
|
-
|
97
|
-
|
294
|
+
|
295
|
+
<span class="summary_desc"><div class='inline'>
|
296
|
+
<p>Erase the data in the IO and Ionian buffers.</p>
|
297
|
+
</div></span>
|
298
|
+
|
299
|
+
</li>
|
98
300
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
301
|
+
|
302
|
+
<li class="public ">
|
303
|
+
<span class="summary_signature">
|
304
|
+
|
305
|
+
<a href="#read_all-instance_method" title="#read_all (instance method)">- (Object) <strong>read_all</strong> </a>
|
306
|
+
|
103
307
|
|
104
|
-
<section class="description">
|
105
308
|
|
106
|
-
|
107
|
-
|
309
|
+
</span>
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
108
317
|
|
109
|
-
|
110
|
-
|
111
|
-
|
318
|
+
|
319
|
+
<span class="summary_desc"><div class='inline'>
|
320
|
+
<p>Read all data in the buffer.</p>
|
321
|
+
</div></span>
|
322
|
+
|
323
|
+
</li>
|
112
324
|
|
113
|
-
|
325
|
+
|
326
|
+
<li class="public ">
|
327
|
+
<span class="summary_signature">
|
328
|
+
|
329
|
+
<a href="#read_match-instance_method" title="#read_match (instance method)">- (Object) <strong>read_match</strong>(**kwargs, &block) </a>
|
330
|
+
|
114
331
|
|
332
|
+
|
333
|
+
</span>
|
334
|
+
|
335
|
+
|
336
|
+
|
115
337
|
|
116
338
|
|
117
339
|
|
118
|
-
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
<span class="summary_desc"><div class='inline'>
|
344
|
+
<p>Read matched data from the buffer.</p>
|
345
|
+
</div></span>
|
346
|
+
|
347
|
+
</li>
|
348
|
+
|
349
|
+
|
350
|
+
<li class="public ">
|
351
|
+
<span class="summary_signature">
|
352
|
+
|
353
|
+
<a href="#register_observer-instance_method" title="#register_observer (instance method)">- (Object) <strong>register_observer</strong>(&block) </a>
|
119
354
|
|
120
355
|
|
121
356
|
|
357
|
+
(also: #on_match)
|
358
|
+
|
359
|
+
</span>
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
<span class="summary_desc"><div class='inline'>
|
370
|
+
<p>Register a block to be called when #run_match receives matched data.</p>
|
371
|
+
</div></span>
|
372
|
+
|
373
|
+
</li>
|
122
374
|
|
375
|
+
|
376
|
+
<li class="public ">
|
377
|
+
<span class="summary_signature">
|
378
|
+
|
379
|
+
<a href="#run_match-instance_method" title="#run_match (instance method)">- (Object) <strong>run_match</strong>(**kwargs) </a>
|
123
380
|
|
124
381
|
|
125
382
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
383
|
+
</span>
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
<span class="summary_desc"><div class='inline'>
|
394
|
+
<p>Start a thread that checks for data and notifies listeners (do |match,
|
395
|
+
socket|).</p>
|
396
|
+
</div></span>
|
397
|
+
|
398
|
+
</li>
|
130
399
|
|
131
400
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
401
|
+
<li class="public ">
|
402
|
+
<span class="summary_signature">
|
403
|
+
|
404
|
+
<a href="#unregister_observer-instance_method" title="#unregister_observer (instance method)">- (Object) <strong>unregister_observer</strong>(&block) </a>
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
</span>
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
<span class="summary_desc"><div class='inline'>
|
419
|
+
<p>Unregister a block from being called when matched data is received.</p>
|
420
|
+
</div></span>
|
421
|
+
|
422
|
+
</li>
|
423
|
+
|
145
424
|
|
146
|
-
</
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
<
|
178
|
-
<
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
425
|
+
</ul>
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
<div id="instance_attr_details" class="attr_details">
|
430
|
+
<h2>Instance Attribute Details</h2>
|
431
|
+
|
432
|
+
|
433
|
+
<span id="ionian_timeout=-instance_method"></span>
|
434
|
+
<div class="method_details first">
|
435
|
+
<h3 class="signature first" id="ionian_timeout-instance_method">
|
436
|
+
|
437
|
+
- (<tt>Object</tt>) <strong>ionian_timeout</strong>
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
</h3><div class="docstring">
|
444
|
+
<div class="discussion">
|
445
|
+
|
446
|
+
<p>Number of seconds to attempt an IO operation before timing out. See
|
447
|
+
standard library IO::select.</p>
|
448
|
+
|
449
|
+
|
450
|
+
</div>
|
451
|
+
</div>
|
452
|
+
<div class="tags">
|
453
|
+
|
454
|
+
|
455
|
+
</div><table class="source_code">
|
456
|
+
<tr>
|
457
|
+
<td>
|
458
|
+
<pre class="lines">
|
459
|
+
|
460
|
+
|
461
|
+
12
|
462
|
+
13
|
463
|
+
14</pre>
|
464
|
+
</td>
|
465
|
+
<td>
|
466
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 12</span>
|
467
|
+
|
468
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ionian_timeout'>ionian_timeout</span>
|
469
|
+
<span class='ivar'>@ionian_timeout</span>
|
470
|
+
<span class='kw'>end</span></pre>
|
471
|
+
</td>
|
472
|
+
</tr>
|
473
|
+
</table>
|
474
|
+
</div>
|
475
|
+
|
476
|
+
</div>
|
477
|
+
|
478
|
+
|
479
|
+
<div id="class_method_details" class="method_details_list">
|
480
|
+
<h2>Class Method Details</h2>
|
481
|
+
|
482
|
+
|
483
|
+
<div class="method_details first">
|
484
|
+
<h3 class="signature first" id="extended-class_method">
|
485
|
+
|
486
|
+
+ (<tt>Object</tt>) <strong>extended</strong>(obj)
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
</h3><div class="docstring">
|
493
|
+
<div class="discussion">
|
494
|
+
|
495
|
+
<p>Called automaticallly when the object is extended with #extend.</p>
|
496
|
+
|
497
|
+
|
498
|
+
</div>
|
499
|
+
</div>
|
500
|
+
<div class="tags">
|
501
|
+
|
502
|
+
|
503
|
+
</div><table class="source_code">
|
504
|
+
<tr>
|
505
|
+
<td>
|
506
|
+
<pre class="lines">
|
507
|
+
|
508
|
+
|
509
|
+
15
|
510
|
+
16
|
511
|
+
17</pre>
|
512
|
+
</td>
|
513
|
+
<td>
|
514
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 15</span>
|
515
|
+
|
516
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_extended'>extended</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
|
517
|
+
<span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_initialize_ionian'>initialize_ionian</span>
|
518
|
+
<span class='kw'>end</span></pre>
|
519
|
+
</td>
|
520
|
+
</tr>
|
521
|
+
</table>
|
522
|
+
</div>
|
523
|
+
|
524
|
+
</div>
|
525
|
+
|
526
|
+
<div id="instance_method_details" class="method_details_list">
|
527
|
+
<h2>Instance Method Details</h2>
|
528
|
+
|
529
|
+
|
530
|
+
<div class="method_details first">
|
531
|
+
<h3 class="signature first" id="expression-instance_method">
|
532
|
+
|
533
|
+
- (<tt>Object</tt>) <strong>expression</strong>
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
</h3><div class="docstring">
|
540
|
+
<div class="discussion">
|
541
|
+
|
542
|
+
<p>Returns the regular expression used for #read_match.</p>
|
543
|
+
|
544
|
+
|
545
|
+
</div>
|
546
|
+
</div>
|
547
|
+
<div class="tags">
|
548
|
+
|
549
|
+
|
550
|
+
</div><table class="source_code">
|
551
|
+
<tr>
|
552
|
+
<td>
|
553
|
+
<pre class="lines">
|
554
|
+
|
555
|
+
|
556
|
+
39
|
557
|
+
40
|
558
|
+
41</pre>
|
559
|
+
</td>
|
560
|
+
<td>
|
561
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 39</span>
|
562
|
+
|
563
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_expression'>expression</span>
|
564
|
+
<span class='ivar'>@ionian_expression</span>
|
565
|
+
<span class='kw'>end</span></pre>
|
566
|
+
</td>
|
567
|
+
</tr>
|
568
|
+
</table>
|
569
|
+
</div>
|
570
|
+
|
571
|
+
<div class="method_details ">
|
572
|
+
<h3 class="signature " id="expression=-instance_method">
|
573
|
+
|
574
|
+
- (<tt>Object</tt>) <strong>expression=</strong>(exp)
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
</h3><div class="docstring">
|
581
|
+
<div class="discussion">
|
582
|
+
|
583
|
+
<p>Set the expression to match against the read buffer. Can be a regular
|
245
584
|
expression specifying capture groups, or a string specifying the separator
|
246
585
|
or line terminator sequence. It is possible to use named captures in a
|
247
586
|
regex, which allows for convienient accessors like <a
|
248
587
|
href=":parameter">match</a>.</p>
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
<
|
258
|
-
<
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
<
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
<
|
327
|
-
|
328
|
-
|
329
|
-
<span class=
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
588
|
+
|
589
|
+
|
590
|
+
</div>
|
591
|
+
</div>
|
592
|
+
<div class="tags">
|
593
|
+
|
594
|
+
|
595
|
+
</div><table class="source_code">
|
596
|
+
<tr>
|
597
|
+
<td>
|
598
|
+
<pre class="lines">
|
599
|
+
|
600
|
+
|
601
|
+
49
|
602
|
+
50
|
603
|
+
51
|
604
|
+
52</pre>
|
605
|
+
</td>
|
606
|
+
<td>
|
607
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 49</span>
|
608
|
+
|
609
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_expression='>expression=</span><span class='lparen'>(</span><span class='id identifier rubyid_exp'>exp</span><span class='rparen'>)</span>
|
610
|
+
<span class='ivar'>@ionian_expression</span> <span class='op'>=</span> <span class='id identifier rubyid_exp'>exp</span>
|
611
|
+
<span class='ivar'>@ionian_expression</span> <span class='op'>=</span> <span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>(.*?)</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_expression'>expression</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_exp'>exp</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span>
|
612
|
+
<span class='kw'>end</span></pre>
|
613
|
+
</td>
|
614
|
+
</tr>
|
615
|
+
</table>
|
616
|
+
</div>
|
617
|
+
|
618
|
+
<div class="method_details ">
|
619
|
+
<h3 class="signature " id="has_data?-instance_method">
|
620
|
+
|
621
|
+
- (<tt>Boolean</tt>) <strong>has_data?</strong>(timeout: 0)
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
</h3><div class="docstring">
|
628
|
+
<div class="discussion">
|
629
|
+
|
630
|
+
<p>Returns true if there is data in the receive buffer. Args:</p>
|
631
|
+
|
632
|
+
<pre class="code ruby"><code class="ruby">Timeout: Number of seconds to wait for data until
|
633
|
+
giving up. Set to nil for blocking.</code></pre>
|
634
|
+
|
635
|
+
|
636
|
+
</div>
|
637
|
+
</div>
|
638
|
+
<div class="tags">
|
639
|
+
|
640
|
+
<p class="tag_title">Returns:</p>
|
641
|
+
<ul class="return">
|
642
|
+
|
643
|
+
<li>
|
644
|
+
|
645
|
+
|
646
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
647
|
+
|
648
|
+
|
649
|
+
|
650
|
+
</li>
|
651
|
+
|
652
|
+
</ul>
|
653
|
+
|
654
|
+
</div><table class="source_code">
|
655
|
+
<tr>
|
656
|
+
<td>
|
657
|
+
<pre class="lines">
|
658
|
+
|
659
|
+
|
660
|
+
34
|
661
|
+
35
|
662
|
+
36</pre>
|
663
|
+
</td>
|
664
|
+
<td>
|
665
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 34</span>
|
666
|
+
|
667
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_data?'>has_data?</span><span class='lparen'>(</span><span class='label'>timeout:</span> <span class='int'>0</span><span class='rparen'>)</span>
|
668
|
+
<span class='op'>::</span><span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_timeout'>timeout</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>true</span> <span class='op'>:</span> <span class='kw'>false</span>
|
669
|
+
<span class='kw'>end</span></pre>
|
670
|
+
</td>
|
671
|
+
</tr>
|
672
|
+
</table>
|
673
|
+
</div>
|
674
|
+
|
675
|
+
<div class="method_details ">
|
676
|
+
<h3 class="signature " id="initialize_ionian-instance_method">
|
677
|
+
|
678
|
+
- (<tt>Object</tt>) <strong>initialize_ionian</strong>
|
679
|
+
|
680
|
+
|
681
|
+
|
682
|
+
|
683
|
+
|
684
|
+
</h3><div class="docstring">
|
685
|
+
<div class="discussion">
|
686
|
+
|
687
|
+
<p>Initialize the Ionian instance variables. This is called automatically if
|
688
|
+
#extend is called on an object.</p>
|
689
|
+
|
690
|
+
|
691
|
+
</div>
|
692
|
+
</div>
|
693
|
+
<div class="tags">
|
694
|
+
|
695
|
+
|
696
|
+
</div><table class="source_code">
|
697
|
+
<tr>
|
698
|
+
<td>
|
699
|
+
<pre class="lines">
|
700
|
+
|
701
|
+
|
702
|
+
21
|
703
|
+
22
|
704
|
+
23
|
705
|
+
24
|
706
|
+
25
|
707
|
+
26
|
708
|
+
27
|
709
|
+
28</pre>
|
710
|
+
</td>
|
711
|
+
<td>
|
712
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 21</span>
|
713
|
+
|
714
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize_ionian'>initialize_ionian</span>
|
715
|
+
<span class='ivar'>@ionian_listeners</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
716
|
+
<span class='ivar'>@ionian_buf</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
717
|
+
<span class='ivar'>@ionian_expression</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(.*?)[\r\n]+</span><span class='regexp_end'>/</span></span>
|
718
|
+
<span class='ivar'>@ionian_timeout</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
719
|
+
<span class='ivar'>@ionian_skip_select</span> <span class='op'>=</span> <span class='kw'>false</span>
|
720
|
+
<span class='ivar'>@ionian_build_methods</span> <span class='op'>=</span> <span class='kw'>true</span>
|
721
|
+
<span class='kw'>end</span></pre>
|
722
|
+
</td>
|
723
|
+
</tr>
|
724
|
+
</table>
|
725
|
+
</div>
|
726
|
+
|
727
|
+
<div class="method_details ">
|
728
|
+
<h3 class="signature " id="purge-instance_method">
|
729
|
+
|
730
|
+
- (<tt>Object</tt>) <strong>purge</strong>
|
731
|
+
|
732
|
+
|
733
|
+
|
734
|
+
|
735
|
+
|
736
|
+
</h3><div class="docstring">
|
737
|
+
<div class="discussion">
|
738
|
+
|
739
|
+
<p>Erase the data in the IO and Ionian buffers. This is typically handled
|
387
740
|
automatically.</p>
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
<
|
397
|
-
<
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
741
|
+
|
742
|
+
|
743
|
+
</div>
|
744
|
+
</div>
|
745
|
+
<div class="tags">
|
746
|
+
|
747
|
+
|
748
|
+
</div><table class="source_code">
|
749
|
+
<tr>
|
750
|
+
<td>
|
751
|
+
<pre class="lines">
|
752
|
+
|
753
|
+
|
754
|
+
153
|
755
|
+
154
|
756
|
+
155
|
757
|
+
156
|
758
|
+
157
|
759
|
+
158
|
760
|
+
159
|
761
|
+
160</pre>
|
762
|
+
</td>
|
763
|
+
<td>
|
764
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 153</span>
|
765
|
+
|
766
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_purge'>purge</span>
|
767
|
+
<span class='comment'># Erase IO buffer.
|
768
|
+
</span> <span class='kw'>while</span> <span class='op'>::</span><span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='int'>0</span>
|
769
|
+
<span class='id identifier rubyid_readpartial'>readpartial</span><span class='lparen'>(</span><span class='int'>0xFFFF</span><span class='rparen'>)</span>
|
770
|
+
<span class='kw'>end</span>
|
771
|
+
|
772
|
+
<span class='ivar'>@ionian_buf</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
773
|
+
<span class='kw'>end</span></pre>
|
774
|
+
</td>
|
775
|
+
</tr>
|
776
|
+
</table>
|
777
|
+
</div>
|
778
|
+
|
779
|
+
<div class="method_details ">
|
780
|
+
<h3 class="signature " id="read_all-instance_method">
|
781
|
+
|
782
|
+
- (<tt>Object</tt>) <strong>read_all</strong>
|
783
|
+
|
784
|
+
|
785
|
+
|
786
|
+
|
787
|
+
|
788
|
+
</h3><div class="docstring">
|
789
|
+
<div class="discussion">
|
790
|
+
|
791
|
+
<p>Read all data in the buffer. An alternative to using #readpartial with a
|
426
792
|
large length.</p>
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
<
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
793
|
+
|
794
|
+
|
795
|
+
</div>
|
796
|
+
</div>
|
797
|
+
<div class="tags">
|
798
|
+
|
799
|
+
|
800
|
+
</div><table class="source_code">
|
801
|
+
<tr>
|
802
|
+
<td>
|
803
|
+
<pre class="lines">
|
804
|
+
|
805
|
+
|
806
|
+
56
|
807
|
+
57
|
808
|
+
58</pre>
|
809
|
+
</td>
|
810
|
+
<td>
|
811
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 56</span>
|
812
|
+
|
813
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_read_all'>read_all</span>
|
814
|
+
<span class='id identifier rubyid_readpartial'>readpartial</span> <span class='int'>0xFFFF</span>
|
815
|
+
<span class='kw'>end</span></pre>
|
816
|
+
</td>
|
817
|
+
</tr>
|
818
|
+
</table>
|
819
|
+
</div>
|
820
|
+
|
821
|
+
<div class="method_details ">
|
822
|
+
<h3 class="signature " id="read_match-instance_method">
|
823
|
+
|
824
|
+
- (<tt>Object</tt>) <strong>read_match</strong>(**kwargs, &block)
|
825
|
+
|
826
|
+
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
</h3><div class="docstring">
|
831
|
+
<div class="discussion">
|
832
|
+
|
833
|
+
<p>Read matched data from the buffer. This method SHOULD NOT be used if
|
834
|
+
#run_match is used.</p>
|
461
835
|
|
462
836
|
<p>Passes matches to the block (do |match|). If there are multiple matches,
|
463
837
|
the block is called multiple times.</p>
|
@@ -470,210 +844,299 @@ with match.pre_match.</p>
|
|
470
844
|
|
471
845
|
<p>Data at the end of the buffer that is not matched can be accessed in the
|
472
846
|
last match with match.post_match. This data remains in the buffer for the
|
473
|
-
next
|
474
|
-
|
847
|
+
next #read_match cycle. This is helpful for protocols like RS232 that do
|
848
|
+
not have packet boundries.</p>
|
475
849
|
|
476
850
|
<p>kwargs:</p>
|
477
851
|
|
478
|
-
<pre>timeout: Timeout in seconds IO::select will block.
|
852
|
+
<pre class="code ruby"><code class="ruby">timeout: Timeout in seconds IO::select will block.
|
479
853
|
expression: Override the expression match for this single
|
480
854
|
method call.
|
481
855
|
notify: Set to false to skip notifying match listener procs.
|
482
856
|
skip_select: Skip over the IO::select statement. Use if you
|
483
857
|
are calling IO::select ahead of this method.
|
484
858
|
build_methods: Build accessor methods from named capture groups.
|
485
|
-
Enabled by default.</pre>
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
<
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
<span class=
|
571
|
-
|
572
|
-
<span class=
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
</
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
<
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
</
|
672
|
-
|
673
|
-
|
674
|
-
<
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
859
|
+
Enabled by default.</code></pre>
|
860
|
+
|
861
|
+
|
862
|
+
</div>
|
863
|
+
</div>
|
864
|
+
<div class="tags">
|
865
|
+
|
866
|
+
|
867
|
+
</div><table class="source_code">
|
868
|
+
<tr>
|
869
|
+
<td>
|
870
|
+
<pre class="lines">
|
871
|
+
|
872
|
+
|
873
|
+
86
|
874
|
+
87
|
875
|
+
88
|
876
|
+
89
|
877
|
+
90
|
878
|
+
91
|
879
|
+
92
|
880
|
+
93
|
881
|
+
94
|
882
|
+
95
|
883
|
+
96
|
884
|
+
97
|
885
|
+
98
|
886
|
+
99
|
887
|
+
100
|
888
|
+
101
|
889
|
+
102
|
890
|
+
103
|
891
|
+
104
|
892
|
+
105
|
893
|
+
106
|
894
|
+
107
|
895
|
+
108
|
896
|
+
109
|
897
|
+
110
|
898
|
+
111
|
899
|
+
112
|
900
|
+
113
|
901
|
+
114
|
902
|
+
115
|
903
|
+
116
|
904
|
+
117
|
905
|
+
118
|
906
|
+
119
|
907
|
+
120
|
908
|
+
121
|
909
|
+
122
|
910
|
+
123
|
911
|
+
124
|
912
|
+
125
|
913
|
+
126
|
914
|
+
127
|
915
|
+
128
|
916
|
+
129
|
917
|
+
130
|
918
|
+
131</pre>
|
919
|
+
</td>
|
920
|
+
<td>
|
921
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 86</span>
|
922
|
+
|
923
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_read_match'>read_match</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
924
|
+
<span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:timeout</span><span class='comma'>,</span> <span class='ivar'>@ionian_timeout</span>
|
925
|
+
<span class='id identifier rubyid_notify'>notify</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:notify</span><span class='comma'>,</span> <span class='kw'>true</span>
|
926
|
+
<span class='id identifier rubyid_skip_select'>skip_select</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:skip_select</span><span class='comma'>,</span> <span class='ivar'>@ionian_skip_select</span>
|
927
|
+
<span class='id identifier rubyid_build_methods'>build_methods</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:build_methods</span><span class='comma'>,</span> <span class='ivar'>@ionian_build_methods</span>
|
928
|
+
|
929
|
+
<span class='id identifier rubyid_exp'>exp</span> <span class='op'>=</span> <span class='id identifier rubyid_kwargs'>kwargs</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span> <span class='symbol'>:expression</span><span class='comma'>,</span> <span class='ivar'>@ionian_expression</span>
|
930
|
+
<span class='id identifier rubyid_exp'>exp</span> <span class='op'>=</span> <span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>(.*?)</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exp'>exp</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_exp'>exp</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span>
|
931
|
+
|
932
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_skip_select'>skip_select</span>
|
933
|
+
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>unless</span> <span class='op'>::</span><span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_timeout'>timeout</span>
|
934
|
+
<span class='kw'>end</span>
|
935
|
+
|
936
|
+
<span class='comment'># Read data from the IO buffer until it's empty.
|
937
|
+
</span> <span class='id identifier rubyid_loop'>loop</span> <span class='kw'>do</span>
|
938
|
+
<span class='ivar'>@ionian_buf</span> <span class='op'><<</span> <span class='id identifier rubyid_readpartial'>readpartial</span><span class='lparen'>(</span><span class='int'>0xFFFF</span><span class='rparen'>)</span>
|
939
|
+
<span class='kw'>break</span> <span class='kw'>unless</span> <span class='op'>::</span><span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='int'>0</span>
|
940
|
+
<span class='kw'>end</span>
|
941
|
+
|
942
|
+
<span class='ivar'>@matches</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
943
|
+
|
944
|
+
<span class='kw'>while</span> <span class='ivar'>@ionian_buf</span> <span class='op'>=~</span> <span class='id identifier rubyid_exp'>exp</span>
|
945
|
+
<span class='ivar'>@matches</span> <span class='op'><<</span> <span class='gvar'>$~</span> <span class='comment'># Match data.
|
946
|
+
</span> <span class='ivar'>@ionian_buf</span> <span class='op'>=</span> <span class='backref'>$'</span> <span class='comment'># Leave post match data in the buffer.
|
947
|
+
</span> <span class='kw'>end</span>
|
948
|
+
|
949
|
+
<span class='comment'># Convert named captures to methods.
|
950
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_build_methods'>build_methods</span>
|
951
|
+
<span class='ivar'>@matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span>
|
952
|
+
<span class='id identifier rubyid_match'>match</span><span class='period'>.</span><span class='id identifier rubyid_names'>names</span><span class='period'>
|
953
|
+
</span><span class='id identifier rubyid_ .map'> .map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='op'>|</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbrace'>}</span><span class='period'>
|
954
|
+
</span><span class='id identifier rubyid_ .each'> .each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_symbol'>symbol</span><span class='op'>|</span> <span class='id identifier rubyid_match'>match</span><span class='period'>.</span><span class='id identifier rubyid_singleton_class'>singleton_class</span><span class='period'>
|
955
|
+
</span><span class='id identifier rubyid_ .send'> .send</span><span class='lparen'>(</span><span class='symbol'>:define_method</span><span class='comma'>,</span> <span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_match'>match</span><span class='lbracket'>[</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> \
|
956
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_match'>match</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span> <span class='id identifier rubyid_symbol'>symbol</span>
|
957
|
+
<span class='rbrace'>}</span>
|
958
|
+
<span class='kw'>end</span>
|
959
|
+
<span class='kw'>end</span>
|
960
|
+
|
961
|
+
<span class='comment'># Pass each match to block.
|
962
|
+
</span> <span class='ivar'>@matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='kw'>yield</span> <span class='id identifier rubyid_match'>match</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
963
|
+
|
964
|
+
<span class='comment'># Notify on_match listeners unless the #run_match thread is active.
|
965
|
+
</span> <span class='ivar'>@matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='id identifier rubyid_notify_listeners'>notify_listeners</span> <span class='id identifier rubyid_match'>match</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_notify'>notify</span> <span class='kw'>and</span> <span class='kw'>not</span> <span class='ivar'>@match_listener</span>
|
966
|
+
|
967
|
+
<span class='ivar'>@matches</span>
|
968
|
+
<span class='kw'>end</span></pre>
|
969
|
+
</td>
|
970
|
+
</tr>
|
971
|
+
</table>
|
972
|
+
</div>
|
973
|
+
|
974
|
+
<div class="method_details ">
|
975
|
+
<h3 class="signature " id="register_observer-instance_method">
|
976
|
+
|
977
|
+
- (<tt>Object</tt>) <strong>register_observer</strong>(&block)
|
978
|
+
|
979
|
+
|
980
|
+
|
981
|
+
<span class="aliases">Also known as:
|
982
|
+
<span class="names"><span id='on_match-instance_method'>on_match</span></span>
|
983
|
+
</span>
|
984
|
+
|
985
|
+
|
986
|
+
|
987
|
+
</h3><div class="docstring">
|
988
|
+
<div class="discussion">
|
989
|
+
|
990
|
+
<p>Register a block to be called when #run_match receives matched data. Method
|
991
|
+
callbacks can be registered with &object.method(:method). Returns a
|
992
|
+
reference to the given block. block = ionian_socket.register_observer { … }</p>
|
993
|
+
|
994
|
+
|
995
|
+
</div>
|
996
|
+
</div>
|
997
|
+
<div class="tags">
|
998
|
+
|
999
|
+
|
1000
|
+
</div><table class="source_code">
|
1001
|
+
<tr>
|
1002
|
+
<td>
|
1003
|
+
<pre class="lines">
|
1004
|
+
|
1005
|
+
|
1006
|
+
166
|
1007
|
+
167
|
1008
|
+
168
|
1009
|
+
169</pre>
|
1010
|
+
</td>
|
1011
|
+
<td>
|
1012
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 166</span>
|
1013
|
+
|
1014
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_register_observer'>register_observer</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1015
|
+
<span class='ivar'>@ionian_listeners</span> <span class='op'><<</span> <span class='id identifier rubyid_block'>block</span> <span class='kw'>unless</span> <span class='ivar'>@ionian_listeners</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_block'>block</span>
|
1016
|
+
<span class='id identifier rubyid_block'>block</span>
|
1017
|
+
<span class='kw'>end</span></pre>
|
1018
|
+
</td>
|
1019
|
+
</tr>
|
1020
|
+
</table>
|
1021
|
+
</div>
|
1022
|
+
|
1023
|
+
<div class="method_details ">
|
1024
|
+
<h3 class="signature " id="run_match-instance_method">
|
1025
|
+
|
1026
|
+
- (<tt>Object</tt>) <strong>run_match</strong>(**kwargs)
|
1027
|
+
|
1028
|
+
|
1029
|
+
|
1030
|
+
|
1031
|
+
|
1032
|
+
</h3><div class="docstring">
|
1033
|
+
<div class="discussion">
|
1034
|
+
|
1035
|
+
<p>Start a thread that checks for data and notifies listeners (do |match,
|
1036
|
+
socket|). Passes kwargs to #read_match. This method SHOULD NOT be used if
|
1037
|
+
#read_match is used.</p>
|
1038
|
+
|
1039
|
+
|
1040
|
+
</div>
|
1041
|
+
</div>
|
1042
|
+
<div class="tags">
|
1043
|
+
|
1044
|
+
|
1045
|
+
</div><table class="source_code">
|
1046
|
+
<tr>
|
1047
|
+
<td>
|
1048
|
+
<pre class="lines">
|
1049
|
+
|
1050
|
+
|
1051
|
+
136
|
1052
|
+
137
|
1053
|
+
138
|
1054
|
+
139
|
1055
|
+
140
|
1056
|
+
141
|
1057
|
+
142
|
1058
|
+
143
|
1059
|
+
144
|
1060
|
+
145
|
1061
|
+
146
|
1062
|
+
147
|
1063
|
+
148
|
1064
|
+
149</pre>
|
1065
|
+
</td>
|
1066
|
+
<td>
|
1067
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 136</span>
|
1068
|
+
|
1069
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_run_match'>run_match</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
1070
|
+
<span class='ivar'>@match_listener</span> <span class='op'>||=</span> <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
|
1071
|
+
<span class='kw'>begin</span>
|
1072
|
+
<span class='kw'>while</span> <span class='kw'>not</span> <span class='id identifier rubyid_closed?'>closed?</span> <span class='kw'>do</span>
|
1073
|
+
<span class='id identifier rubyid_matches'>matches</span> <span class='op'>=</span> <span class='id identifier rubyid_read_match'>read_match</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span>
|
1074
|
+
<span class='id identifier rubyid_matches'>matches</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_match'>match</span><span class='op'>|</span> <span class='id identifier rubyid_notify_listeners'>notify_listeners</span> <span class='id identifier rubyid_match'>match</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_matches'>matches</span>
|
1075
|
+
<span class='kw'>end</span>
|
1076
|
+
<span class='kw'>rescue</span> <span class='const'>EOFError</span>
|
1077
|
+
<span class='kw'>rescue</span> <span class='const'>IOError</span>
|
1078
|
+
<span class='kw'>ensure</span>
|
1079
|
+
<span class='ivar'>@match_listener</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
1080
|
+
<span class='kw'>end</span>
|
1081
|
+
<span class='kw'>end</span>
|
1082
|
+
<span class='kw'>end</span></pre>
|
1083
|
+
</td>
|
1084
|
+
</tr>
|
1085
|
+
</table>
|
1086
|
+
</div>
|
1087
|
+
|
1088
|
+
<div class="method_details ">
|
1089
|
+
<h3 class="signature " id="unregister_observer-instance_method">
|
1090
|
+
|
1091
|
+
- (<tt>Object</tt>) <strong>unregister_observer</strong>(&block)
|
1092
|
+
|
1093
|
+
|
1094
|
+
|
1095
|
+
|
1096
|
+
|
1097
|
+
</h3><div class="docstring">
|
1098
|
+
<div class="discussion">
|
1099
|
+
|
1100
|
+
<p>Unregister a block from being called when matched data is received.</p>
|
1101
|
+
|
1102
|
+
|
1103
|
+
</div>
|
1104
|
+
</div>
|
1105
|
+
<div class="tags">
|
1106
|
+
|
1107
|
+
|
1108
|
+
</div><table class="source_code">
|
1109
|
+
<tr>
|
1110
|
+
<td>
|
1111
|
+
<pre class="lines">
|
1112
|
+
|
1113
|
+
|
1114
|
+
174
|
1115
|
+
175
|
1116
|
+
176
|
1117
|
+
177</pre>
|
1118
|
+
</td>
|
1119
|
+
<td>
|
1120
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/extension/io.rb', line 174</span>
|
1121
|
+
|
1122
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_unregister_observer'>unregister_observer</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
1123
|
+
<span class='ivar'>@ionian_listeners</span><span class='period'>.</span><span class='id identifier rubyid_delete_if'>delete_if</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_o'>o</span> <span class='op'>==</span> <span class='id identifier rubyid_block'>block</span><span class='rbrace'>}</span>
|
1124
|
+
<span class='id identifier rubyid_block'>block</span>
|
1125
|
+
<span class='kw'>end</span></pre>
|
1126
|
+
</td>
|
1127
|
+
</tr>
|
1128
|
+
</table>
|
1129
|
+
</div>
|
1130
|
+
|
1131
|
+
</div>
|
1132
|
+
|
1133
|
+
</div>
|
1134
|
+
|
1135
|
+
<div id="footer">
|
1136
|
+
Generated on Sat Mar 15 21:04:53 2014 by
|
1137
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1138
|
+
0.8.7.3 (ruby-2.1.1).
|
1139
|
+
</div>
|
679
1140
|
|
1141
|
+
</body>
|
1142
|
+
</html>
|