ionian 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -2
- data/doc/Ionian/Extension/IO.html +36 -32
- data/doc/Ionian/Extension/Socket.html +1 -1
- data/doc/Ionian/Extension.html +1 -1
- data/doc/Ionian/Server.html +337 -64
- data/doc/Ionian/Socket.html +47 -47
- data/doc/Ionian.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +16 -3
- data/doc/file.license.html +1 -1
- data/doc/index.html +16 -3
- data/doc/method_list.html +73 -55
- data/doc/top-level-namespace.html +1 -1
- data/lib/ionian/extension/io.rb +4 -1
- data/lib/ionian/server.rb +38 -6
- data/lib/ionian/socket.rb +7 -6
- metadata +2 -2
data/doc/Ionian/Socket.html
CHANGED
@@ -566,7 +566,7 @@ any string not already ending with one.</p>
|
|
566
566
|
|
567
567
|
<p>Args:</p>
|
568
568
|
|
569
|
-
<pre class="code ruby"><code class="ruby">host: IP or hostname to connect to.
|
569
|
+
<pre class="code ruby"><code class="ruby">host: IP or hostname to connect to. Can contain the port in the format "host:port".
|
570
570
|
port: Connection's port number. Default is 23. Unused by :unix protocol.
|
571
571
|
protocol: Type of socket to create. :tcp, :udp, :unix. Default is :tcp.
|
572
572
|
:udp will be automatically selected for addresses in the multicast range.
|
@@ -593,12 +593,6 @@ expression: Overrides the #read_match regular expression for received data.</cod
|
|
593
593
|
<pre class="lines">
|
594
594
|
|
595
595
|
|
596
|
-
34
|
597
|
-
35
|
598
|
-
36
|
599
|
-
37
|
600
|
-
38
|
601
|
-
39
|
602
596
|
40
|
603
597
|
41
|
604
598
|
42
|
@@ -653,10 +647,16 @@ expression: Overrides the #read_match regular expression for received data.</cod
|
|
653
647
|
91
|
654
648
|
92
|
655
649
|
93
|
656
|
-
94
|
650
|
+
94
|
651
|
+
95
|
652
|
+
96
|
653
|
+
97
|
654
|
+
98
|
655
|
+
99
|
656
|
+
100</pre>
|
657
657
|
</td>
|
658
658
|
<td>
|
659
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
659
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 40</span>
|
660
660
|
|
661
661
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span>
|
662
662
|
<span class='ivar'>@socket</span> <span class='op'>=</span> <span class='id identifier rubyid_existing_socket'>existing_socket</span>
|
@@ -891,12 +891,12 @@ expression: Overrides the #read_match regular expression for received data.</cod
|
|
891
891
|
<pre class="lines">
|
892
892
|
|
893
893
|
|
894
|
-
|
895
|
-
|
896
|
-
|
894
|
+
19
|
895
|
+
20
|
896
|
+
21</pre>
|
897
897
|
</td>
|
898
898
|
<td>
|
899
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
899
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 19</span>
|
900
900
|
|
901
901
|
<span class='kw'>def</span> <span class='id identifier rubyid_protocol'>protocol</span>
|
902
902
|
<span class='ivar'>@protocol</span>
|
@@ -952,13 +952,13 @@ expression: Overrides the #read_match regular expression for received data.</cod
|
|
952
952
|
<pre class="lines">
|
953
953
|
|
954
954
|
|
955
|
-
169
|
956
955
|
170
|
957
956
|
171
|
958
|
-
172
|
957
|
+
172
|
958
|
+
173</pre>
|
959
959
|
</td>
|
960
960
|
<td>
|
961
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
961
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 170</span>
|
962
962
|
|
963
963
|
<span class='kw'>def</span> <span class='id identifier rubyid_closed?'>closed?</span>
|
964
964
|
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>unless</span> <span class='ivar'>@socket</span>
|
@@ -996,7 +996,6 @@ Block yields received match. See Ionian::Extension::IO#read_match.</p>
|
|
996
996
|
<pre class="lines">
|
997
997
|
|
998
998
|
|
999
|
-
121
|
1000
999
|
122
|
1001
1000
|
123
|
1002
1001
|
124
|
@@ -1011,10 +1010,11 @@ Block yields received match. See Ionian::Extension::IO#read_match.</p>
|
|
1011
1010
|
133
|
1012
1011
|
134
|
1013
1012
|
135
|
1014
|
-
136
|
1013
|
+
136
|
1014
|
+
137</pre>
|
1015
1015
|
</td>
|
1016
1016
|
<td>
|
1017
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1017
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 122</span>
|
1018
1018
|
|
1019
1019
|
<span class='kw'>def</span> <span class='id identifier rubyid_cmd'>cmd</span> <span class='id identifier rubyid_string'>string</span><span class='comma'>,</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>
|
1020
1020
|
<span class='id identifier rubyid_create_socket'>create_socket</span> <span class='kw'>unless</span> <span class='ivar'>@persistent</span>
|
@@ -1063,12 +1063,12 @@ Block yields received match. See Ionian::Extension::IO#read_match.</p>
|
|
1063
1063
|
<pre class="lines">
|
1064
1064
|
|
1065
1065
|
|
1066
|
-
102
|
1067
1066
|
103
|
1068
|
-
104
|
1067
|
+
104
|
1068
|
+
105</pre>
|
1069
1069
|
</td>
|
1070
1070
|
<td>
|
1071
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1071
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 103</span>
|
1072
1072
|
|
1073
1073
|
<span class='kw'>def</span> <span class='id identifier rubyid_expression'>expression</span>
|
1074
1074
|
<span class='ivar'>@expression</span> <span class='op'>||</span> <span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_expression'>expression</span>
|
@@ -1104,13 +1104,13 @@ Block yields received match. See Ionian::Extension::IO#read_match.</p>
|
|
1104
1104
|
<pre class="lines">
|
1105
1105
|
|
1106
1106
|
|
1107
|
-
107
|
1108
1107
|
108
|
1109
1108
|
109
|
1110
|
-
110
|
1109
|
+
110
|
1110
|
+
111</pre>
|
1111
1111
|
</td>
|
1112
1112
|
<td>
|
1113
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1113
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 108</span>
|
1114
1114
|
|
1115
1115
|
<span class='kw'>def</span> <span class='id identifier rubyid_expression='>expression=</span> <span class='id identifier rubyid_exp'>exp</span>
|
1116
1116
|
<span class='ivar'>@expression</span> <span class='op'>=</span> <span class='id identifier rubyid_exp'>exp</span>
|
@@ -1148,12 +1148,12 @@ non-persistent sockets.</p>
|
|
1148
1148
|
<pre class="lines">
|
1149
1149
|
|
1150
1150
|
|
1151
|
-
176
|
1152
1151
|
177
|
1153
|
-
178
|
1152
|
+
178
|
1153
|
+
179</pre>
|
1154
1154
|
</td>
|
1155
1155
|
<td>
|
1156
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1156
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 177</span>
|
1157
1157
|
|
1158
1158
|
<span class='kw'>def</span> <span class='id identifier rubyid_flush'>flush</span>
|
1159
1159
|
<span class='ivar'>@socket</span><span class='period'>.</span><span class='id identifier rubyid_flush'>flush</span> <span class='kw'>if</span> <span class='ivar'>@persistent</span>
|
@@ -1205,13 +1205,13 @@ non-persistent sockets.</p>
|
|
1205
1205
|
<pre class="lines">
|
1206
1206
|
|
1207
1207
|
|
1208
|
-
163
|
1209
1208
|
164
|
1210
1209
|
165
|
1211
|
-
166
|
1210
|
+
166
|
1211
|
+
167</pre>
|
1212
1212
|
</td>
|
1213
1213
|
<td>
|
1214
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1214
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 164</span>
|
1215
1215
|
|
1216
1216
|
<span class='kw'>def</span> <span class='id identifier rubyid_has_data?'>has_data?</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span>
|
1217
1217
|
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='ivar'>@socket</span>
|
@@ -1261,12 +1261,12 @@ non-persistent sockets.</p>
|
|
1261
1261
|
<pre class="lines">
|
1262
1262
|
|
1263
1263
|
|
1264
|
-
113
|
1265
1264
|
114
|
1266
|
-
115
|
1265
|
+
115
|
1266
|
+
116</pre>
|
1267
1267
|
</td>
|
1268
1268
|
<td>
|
1269
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1269
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 114</span>
|
1270
1270
|
|
1271
1271
|
<span class='kw'>def</span> <span class='id identifier rubyid_persistent?'>persistent?</span>
|
1272
1272
|
<span class='ivar'>@persistent</span> <span class='op'>==</span> <span class='kw'>false</span> <span class='op'>||</span> <span class='ivar'>@persistent</span> <span class='op'>==</span> <span class='kw'>nil</span> <span class='op'>?</span> <span class='kw'>false</span> <span class='op'>:</span> <span class='kw'>true</span>
|
@@ -1303,12 +1303,12 @@ any string not already ending with one.</p>
|
|
1303
1303
|
<pre class="lines">
|
1304
1304
|
|
1305
1305
|
|
1306
|
-
182
|
1307
1306
|
183
|
1308
|
-
184
|
1307
|
+
184
|
1308
|
+
185</pre>
|
1309
1309
|
</td>
|
1310
1310
|
<td>
|
1311
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1311
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 183</span>
|
1312
1312
|
|
1313
1313
|
<span class='kw'>def</span> <span class='id identifier rubyid_puts'>puts</span> <span class='op'>*</span><span class='id identifier rubyid_string'>string</span>
|
1314
1314
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='id identifier rubyid_string'>string</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='op'>|</span> <span class='id identifier rubyid_s'>s</span><span class='period'>.</span><span class='id identifier rubyid_chomp'>chomp</span> <span class='rbrace'>}</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_content'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span>
|
@@ -1350,14 +1350,14 @@ reference to the given block. block = ionian_socket.register_observer { … }</p
|
|
1350
1350
|
<pre class="lines">
|
1351
1351
|
|
1352
1352
|
|
1353
|
-
142
|
1354
1353
|
143
|
1355
1354
|
144
|
1356
1355
|
145
|
1357
|
-
146
|
1356
|
+
146
|
1357
|
+
147</pre>
|
1358
1358
|
</td>
|
1359
1359
|
<td>
|
1360
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1360
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 143</span>
|
1361
1361
|
|
1362
1362
|
<span class='kw'>def</span> <span class='id identifier rubyid_register_observer'>register_observer</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span>
|
1363
1363
|
<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>
|
@@ -1395,14 +1395,14 @@ reference to the given block. block = ionian_socket.register_observer { … }</p
|
|
1395
1395
|
<pre class="lines">
|
1396
1396
|
|
1397
1397
|
|
1398
|
-
151
|
1399
1398
|
152
|
1400
1399
|
153
|
1401
1400
|
154
|
1402
|
-
155
|
1401
|
+
155
|
1402
|
+
156</pre>
|
1403
1403
|
</td>
|
1404
1404
|
<td>
|
1405
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1405
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 152</span>
|
1406
1406
|
|
1407
1407
|
<span class='kw'>def</span> <span class='id identifier rubyid_unregister_observer'>unregister_observer</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span>
|
1408
1408
|
<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>
|
@@ -1444,7 +1444,6 @@ reference to the given block. block = ionian_socket.register_observer { … }</p
|
|
1444
1444
|
<pre class="lines">
|
1445
1445
|
|
1446
1446
|
|
1447
|
-
188
|
1448
1447
|
189
|
1449
1448
|
190
|
1450
1449
|
191
|
@@ -1464,10 +1463,11 @@ reference to the given block. block = ionian_socket.register_observer { … }</p
|
|
1464
1463
|
205
|
1465
1464
|
206
|
1466
1465
|
207
|
1467
|
-
208
|
1466
|
+
208
|
1467
|
+
209</pre>
|
1468
1468
|
</td>
|
1469
1469
|
<td>
|
1470
|
-
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line
|
1470
|
+
<pre class="code"><span class="info file"># File 'lib/ionian/socket.rb', line 189</span>
|
1471
1471
|
|
1472
1472
|
<span class='kw'>def</span> <span class='id identifier rubyid_write'>write</span> <span class='id identifier rubyid_string'>string</span>
|
1473
1473
|
<span class='id identifier rubyid_create_socket'>create_socket</span> <span class='kw'>unless</span> <span class='ivar'>@persistent</span>
|
@@ -1500,7 +1500,7 @@ reference to the given block. block = ionian_socket.register_observer { … }</p
|
|
1500
1500
|
</div>
|
1501
1501
|
|
1502
1502
|
<div id="footer">
|
1503
|
-
Generated on
|
1503
|
+
Generated on Sat Apr 12 13:24:31 2014 by
|
1504
1504
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1505
1505
|
0.8.7.4 (ruby-2.1.1).
|
1506
1506
|
</div>
|
data/doc/Ionian.html
CHANGED
@@ -123,7 +123,7 @@ Features regular expression matching and notification of received data.</p>
|
|
123
123
|
</div>
|
124
124
|
|
125
125
|
<div id="footer">
|
126
|
-
Generated on
|
126
|
+
Generated on Sat Apr 12 13:24:31 2014 by
|
127
127
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
128
128
|
0.8.7.4 (ruby-2.1.1).
|
129
129
|
</div>
|
data/doc/_index.html
CHANGED
@@ -155,7 +155,7 @@
|
|
155
155
|
</div>
|
156
156
|
|
157
157
|
<div id="footer">
|
158
|
-
Generated on
|
158
|
+
Generated on Sat Apr 12 13:24:31 2014 by
|
159
159
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
160
160
|
0.8.7.4 (ruby-2.1.1).
|
161
161
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -98,8 +98,7 @@
|
|
98
98
|
<pre class="code ruby"><code class="ruby"><span class='comment'># A simple IRC client.
|
99
99
|
</span>
|
100
100
|
<span class='id identifier rubyid_socket'>socket</span> <span class='op'>=</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Socket</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> \
|
101
|
-
<span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>chat.freenode.net</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
102
|
-
<span class='label'>port:</span> <span class='int'>6667</span><span class='comma'>,</span>
|
101
|
+
<span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>chat.freenode.net:6667</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
103
102
|
<span class='comment'># Break up the matches into named captures so it's easier
|
104
103
|
</span> <span class='comment'># to sort through the server's responses.
|
105
104
|
</span> <span class='label'>expression:</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>:(?<server>.*?)\s*:(?<msg>.*?)[\r\n]+</span><span class='regexp_end'>/</span></span>
|
@@ -121,10 +120,24 @@
|
|
121
120
|
<span class='kw'>end</span>
|
122
121
|
<span class='kw'>end</span>
|
123
122
|
</code></pre>
|
123
|
+
|
124
|
+
<h3>Simple Server</h3>
|
125
|
+
|
126
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_host'>host</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>localhost:5000</span><span class='tstring_end'>'</span></span>
|
127
|
+
|
128
|
+
<span class='id identifier rubyid_server'>server</span> <span class='op'>=</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Server</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='label'>interface:</span> <span class='id identifier rubyid_host'>host</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_client'>client</span><span class='op'>|</span>
|
129
|
+
<span class='comment'># Greet the connected client.
|
130
|
+
</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Welcome! You are connected to the server.\n</span><span class='tstring_end'>"</span></span>
|
131
|
+
<span class='kw'>end</span>
|
132
|
+
|
133
|
+
<span class='id identifier rubyid_socket'>socket</span> <span class='op'>=</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Socket</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='label'>host:</span> <span class='id identifier rubyid_host'>host</span>
|
134
|
+
<span class='comment'># Retrieve the greeting message.
|
135
|
+
</span><span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_socket'>socket</span><span class='period'>.</span><span class='id identifier rubyid_read_all'>read_all</span>
|
136
|
+
</code></pre>
|
124
137
|
</div></div>
|
125
138
|
|
126
139
|
<div id="footer">
|
127
|
-
Generated on
|
140
|
+
Generated on Sat Apr 12 13:24:31 2014 by
|
128
141
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
142
|
0.8.7.4 (ruby-2.1.1).
|
130
143
|
</div>
|
data/doc/file.license.html
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
<div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2013 Alex McLain<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the "Software"), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.
|
65
65
|
|
66
66
|
<div id="footer">
|
67
|
-
Generated on
|
67
|
+
Generated on Sat Apr 12 13:24:31 2014 by
|
68
68
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
69
69
|
0.8.7.4 (ruby-2.1.1).
|
70
70
|
</div>
|
data/doc/index.html
CHANGED
@@ -98,8 +98,7 @@
|
|
98
98
|
<pre class="code ruby"><code class="ruby"><span class='comment'># A simple IRC client.
|
99
99
|
</span>
|
100
100
|
<span class='id identifier rubyid_socket'>socket</span> <span class='op'>=</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Socket</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> \
|
101
|
-
<span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>chat.freenode.net</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
102
|
-
<span class='label'>port:</span> <span class='int'>6667</span><span class='comma'>,</span>
|
101
|
+
<span class='label'>host:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>chat.freenode.net:6667</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
103
102
|
<span class='comment'># Break up the matches into named captures so it's easier
|
104
103
|
</span> <span class='comment'># to sort through the server's responses.
|
105
104
|
</span> <span class='label'>expression:</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>:(?<server>.*?)\s*:(?<msg>.*?)[\r\n]+</span><span class='regexp_end'>/</span></span>
|
@@ -121,10 +120,24 @@
|
|
121
120
|
<span class='kw'>end</span>
|
122
121
|
<span class='kw'>end</span>
|
123
122
|
</code></pre>
|
123
|
+
|
124
|
+
<h3>Simple Server</h3>
|
125
|
+
|
126
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_host'>host</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>localhost:5000</span><span class='tstring_end'>'</span></span>
|
127
|
+
|
128
|
+
<span class='id identifier rubyid_server'>server</span> <span class='op'>=</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Server</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='label'>interface:</span> <span class='id identifier rubyid_host'>host</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_client'>client</span><span class='op'>|</span>
|
129
|
+
<span class='comment'># Greet the connected client.
|
130
|
+
</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Welcome! You are connected to the server.\n</span><span class='tstring_end'>"</span></span>
|
131
|
+
<span class='kw'>end</span>
|
132
|
+
|
133
|
+
<span class='id identifier rubyid_socket'>socket</span> <span class='op'>=</span> <span class='const'>Ionian</span><span class='op'>::</span><span class='const'>Socket</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='label'>host:</span> <span class='id identifier rubyid_host'>host</span>
|
134
|
+
<span class='comment'># Retrieve the greeting message.
|
135
|
+
</span><span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_socket'>socket</span><span class='period'>.</span><span class='id identifier rubyid_read_all'>read_all</span>
|
136
|
+
</code></pre>
|
124
137
|
</div></div>
|
125
138
|
|
126
139
|
<div id="footer">
|
127
|
-
Generated on
|
140
|
+
Generated on Sat Apr 12 13:24:31 2014 by
|
128
141
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
142
|
0.8.7.4 (ruby-2.1.1).
|
130
143
|
</div>
|