safubot 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardoc/checksums +9 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +52 -1
- data/doc/Safubot/Bot.html +1287 -652
- data/doc/Safubot/Evented.html +409 -276
- data/doc/Safubot/KnownUser.html +476 -254
- data/doc/Safubot/Log.html +184 -192
- data/doc/Safubot/Query.html +131 -164
- data/doc/Safubot/Request.html +158 -147
- data/doc/Safubot/Response.html +92 -135
- data/doc/Safubot/Test.html +166 -187
- data/doc/Safubot/Twitter/Bot.html +1005 -455
- data/doc/Safubot/Twitter/DirectMessage.html +417 -238
- data/doc/Safubot/Twitter/Tweet.html +725 -398
- data/doc/Safubot/Twitter.html +69 -116
- data/doc/Safubot/XMPP/Bot.html +625 -303
- data/doc/Safubot/XMPP/Message.html +372 -217
- data/doc/Safubot/XMPP.html +69 -116
- data/doc/Safubot.html +155 -126
- data/doc/_index.html +294 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.README.html +140 -0
- data/doc/file_list.html +49 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +129 -101
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +167 -0
- data/doc/js/jquery.js +3 -5
- data/doc/method_list.html +638 -0
- data/doc/top-level-namespace.html +103 -0
- data/lib/safubot/bot.rb +22 -20
- data/lib/safubot/known_user.rb +2 -0
- data/lib/safubot/twitter.rb +30 -26
- data/lib/safubot/version.rb +1 -1
- data/lib/safubot/xmpp.rb +20 -14
- data/safubot.gemspec +1 -0
- metadata +50 -71
- data/doc/Gemfile.html +0 -119
- data/doc/Object.html +0 -171
- data/doc/Rakefile.html +0 -117
- data/doc/created.rid +0 -14
- data/doc/foo_rb.html +0 -115
- data/doc/images/add.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 -153
- data/doc/js/navigation.js +0 -142
- data/doc/js/search.js +0 -94
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/lib/safubot/bot_rb.html +0 -115
- data/doc/lib/safubot/evented_rb.html +0 -115
- data/doc/lib/safubot/known_user_rb.html +0 -115
- data/doc/lib/safubot/log_rb.html +0 -115
- data/doc/lib/safubot/safubot_rb.html +0 -115
- data/doc/lib/safubot/spec/bot_spec_rb.html +0 -115
- data/doc/lib/safubot/spec/twitter_spec_rb.html +0 -137
- data/doc/lib/safubot/test_helper_rb.html +0 -115
- data/doc/lib/safubot/twitter_rb.html +0 -115
- data/doc/lib/safubot/version_rb.html +0 -115
- data/doc/lib/safubot/xmpp_rb.html +0 -115
- data/doc/lib/safubot_rb.html +0 -115
- data/doc/rdoc.css +0 -543
- data/doc/table_of_contents.html +0 -224
data/doc/Safubot/Evented.html
CHANGED
@@ -1,346 +1,479 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta content="text/html; charset=
|
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: Safubot::Evented
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.3
|
10
|
+
|
11
|
+
</title>
|
6
12
|
|
7
|
-
<
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
14
|
|
9
|
-
<link type="text/css" media="screen"
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
16
|
|
11
|
-
<script type="text/javascript">
|
12
|
-
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '..';
|
19
|
+
if (relpath != '') relpath += '/';
|
13
20
|
</script>
|
14
21
|
|
15
|
-
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8" src="../js/
|
18
|
-
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
19
|
-
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
20
|
-
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
21
|
-
|
22
|
-
|
23
|
-
<body id="top" class="module">
|
24
|
-
<nav id="metadata">
|
25
|
-
<nav id="home-section" class="section">
|
26
|
-
<h3 class="section-header">
|
27
|
-
<a href="../index.html">Home</a>
|
28
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
29
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
-
</h3>
|
31
|
-
</nav>
|
32
|
-
|
33
|
-
|
34
|
-
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
-
<form action="#" method="get" accept-charset="utf-8">
|
36
|
-
<h3 class="section-header">
|
37
|
-
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
-
</h3>
|
40
|
-
</form>
|
41
|
-
|
42
|
-
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
-
</nav>
|
44
|
-
|
45
|
-
|
46
|
-
<div id="file-metadata">
|
47
|
-
<nav id="file-list-section" class="section">
|
48
|
-
<h3 class="section-header">Defined In</h3>
|
49
|
-
<ul>
|
50
|
-
<li>lib/safubot/evented.rb
|
51
|
-
</ul>
|
52
|
-
</nav>
|
22
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
53
25
|
|
54
|
-
|
55
|
-
</div>
|
56
26
|
|
57
|
-
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
58
32
|
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="../_index.html">Index (E)</a> »
|
37
|
+
<span class='title'><span class='object_link'><a href="../Safubot.html" title="Safubot (module)">Safubot</a></span></span>
|
38
|
+
»
|
39
|
+
<span class="title">Evented</span>
|
40
|
+
|
41
|
+
|
42
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div id="search">
|
46
|
+
|
47
|
+
<a id="class_list_link" href="#">Class List</a>
|
48
|
+
|
49
|
+
<a id="method_list_link" href="#">Method List</a>
|
50
|
+
|
51
|
+
<a id="file_list_link" href="#">File List</a>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
<div class="clear"></div>
|
55
|
+
</div>
|
59
56
|
|
57
|
+
<iframe id="search_frame"></iframe>
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
<div id="content"><h1>Module: Safubot::Evented
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
64
|
|
65
|
-
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
66
68
|
|
67
|
-
|
69
|
+
|
68
70
|
|
69
|
-
|
71
|
+
|
72
|
+
|
73
|
+
<dt class="r1">Included in:</dt>
|
74
|
+
<dd class="r1"><span class='object_link'><a href="Bot.html" title="Safubot::Bot (class)">Bot</a></span>, <span class='object_link'><a href="Twitter/Bot.html" title="Safubot::Twitter::Bot (class)">Twitter::Bot</a></span>, <span class='object_link'><a href="XMPP/Bot.html" title="Safubot::XMPP::Bot (class)">XMPP::Bot</a></span></dd>
|
70
75
|
|
71
|
-
|
76
|
+
|
77
|
+
|
78
|
+
<dt class="r2 last">Defined in:</dt>
|
79
|
+
<dd class="r2 last">lib/safubot/evented.rb</dd>
|
80
|
+
|
81
|
+
</dl>
|
82
|
+
<div class="clear"></div>
|
83
|
+
|
84
|
+
<h2>Overview</h2><div class="docstring">
|
85
|
+
<div class="discussion">
|
86
|
+
<p>
|
87
|
+
A mixin granting simple event firing and handler binding.
|
88
|
+
</p>
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
<div class="tags">
|
94
|
+
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<h2>
|
103
|
+
Instance Method Summary
|
104
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
105
|
+
</h2>
|
106
|
+
|
107
|
+
<ul class="summary">
|
108
|
+
|
109
|
+
<li class="public ">
|
110
|
+
<span class="summary_signature">
|
72
111
|
|
73
|
-
|
112
|
+
<a href="#bind-instance_method" title="#bind (instance method)">- (Object) <strong>bind</strong>(evid, handler) </a>
|
74
113
|
|
75
|
-
|
114
|
+
|
76
115
|
|
77
|
-
</
|
78
|
-
|
116
|
+
</span>
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
79
123
|
|
80
|
-
|
124
|
+
|
125
|
+
<span class="summary_desc"><div class='inline'><p>
|
126
|
+
Binds an event handler, which is a Hash of the form:.
|
127
|
+
</p>
|
128
|
+
</div></span>
|
129
|
+
|
130
|
+
</li>
|
81
131
|
|
82
|
-
|
83
|
-
|
84
|
-
<
|
132
|
+
|
133
|
+
<li class="public ">
|
134
|
+
<span class="summary_signature">
|
135
|
+
|
136
|
+
<a href="#emit-instance_method" title="#emit (instance method)">- (Object) <strong>emit</strong>(evid, *args) </a>
|
137
|
+
|
85
138
|
|
86
|
-
|
139
|
+
|
140
|
+
</span>
|
141
|
+
|
142
|
+
|
143
|
+
|
87
144
|
|
88
|
-
<li class="file"><a href="../Gemfile.html">Gemfile</a>
|
89
145
|
|
90
|
-
<li class="file"><a href="../Rakefile.html">Rakefile</a>
|
91
146
|
|
92
|
-
</ul>
|
93
|
-
</nav>
|
94
147
|
|
95
|
-
|
96
|
-
|
148
|
+
|
149
|
+
<span class="summary_desc"><div class='inline'><p>
|
150
|
+
Fires an evid event with the given arguments.
|
151
|
+
</p>
|
152
|
+
</div></span>
|
153
|
+
|
154
|
+
</li>
|
155
|
+
|
156
|
+
|
157
|
+
<li class="public ">
|
158
|
+
<span class="summary_signature">
|
159
|
+
|
160
|
+
<a href="#on-instance_method" title="#on (instance method)">- (Object) <strong>on</strong>(evid, opts = {}, &callback) </a>
|
161
|
+
|
97
162
|
|
98
|
-
|
163
|
+
|
164
|
+
</span>
|
99
165
|
|
100
|
-
<li><a href="../Safubot.html">Safubot</a>
|
101
166
|
|
102
|
-
<li><a href="../Safubot/Bot.html">Safubot::Bot</a>
|
103
167
|
|
104
|
-
<li><a href="../Safubot/Evented.html">Safubot::Evented</a>
|
105
168
|
|
106
|
-
<li><a href="../Safubot/KnownUser.html">Safubot::KnownUser</a>
|
107
169
|
|
108
|
-
<li><a href="../Safubot/Log.html">Safubot::Log</a>
|
109
170
|
|
110
|
-
|
171
|
+
|
111
172
|
|
112
|
-
<
|
173
|
+
<span class="summary_desc"><div class='inline'><p>
|
174
|
+
Binds a block to the specified event id.
|
175
|
+
</p>
|
176
|
+
</div></span>
|
113
177
|
|
114
|
-
|
178
|
+
</li>
|
179
|
+
|
180
|
+
|
181
|
+
<li class="public ">
|
182
|
+
<span class="summary_signature">
|
183
|
+
|
184
|
+
<a href="#once-instance_method" title="#once (instance method)">- (Object) <strong>once</strong>(evid, opts = {}, &callback) </a>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
</span>
|
115
189
|
|
116
|
-
<li><a href="../Safubot/Test.html">Safubot::Test</a>
|
117
190
|
|
118
|
-
<li><a href="../Safubot/Twitter.html">Safubot::Twitter</a>
|
119
191
|
|
120
|
-
<li><a href="../Safubot/Twitter/Bot.html">Safubot::Twitter::Bot</a>
|
121
192
|
|
122
|
-
<li><a href="../Safubot/Twitter/DirectMessage.html">Safubot::Twitter::DirectMessage</a>
|
123
193
|
|
124
|
-
<li><a href="../Safubot/Twitter/Tweet.html">Safubot::Twitter::Tweet</a>
|
125
194
|
|
126
|
-
|
195
|
+
|
196
|
+
|
197
|
+
<span class="summary_desc"><div class='inline'><p>
|
198
|
+
Binds a block to the specified event id, to be executed only once.
|
199
|
+
</p>
|
200
|
+
</div></span>
|
201
|
+
|
202
|
+
</li>
|
203
|
+
|
204
|
+
|
205
|
+
<li class="public ">
|
206
|
+
<span class="summary_signature">
|
207
|
+
|
208
|
+
<a href="#unbind-instance_method" title="#unbind (instance method)">- (Object) <strong>unbind</strong>(handler) </a>
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
</span>
|
213
|
+
|
214
|
+
|
127
215
|
|
128
|
-
<li><a href="../Safubot/XMPP/Bot.html">Safubot::XMPP::Bot</a>
|
129
216
|
|
130
|
-
<li><a href="../Safubot/XMPP/Message.html">Safubot::XMPP::Message</a>
|
131
217
|
|
132
|
-
<li><a href="../Object.html">Object</a>
|
133
218
|
|
134
|
-
</ul>
|
135
|
-
</nav>
|
136
219
|
|
137
|
-
|
138
|
-
|
220
|
+
|
221
|
+
<span class="summary_desc"><div class='inline'><p>
|
222
|
+
Unbinds the given handler.
|
223
|
+
</p>
|
224
|
+
</div></span>
|
225
|
+
|
226
|
+
</li>
|
139
227
|
|
140
|
-
|
141
|
-
|
228
|
+
|
229
|
+
</ul>
|
230
|
+
|
142
231
|
|
143
|
-
<div id="description" class="description">
|
144
|
-
|
145
|
-
<p>A mixin granting simple event firing and handler binding.</p>
|
146
232
|
|
147
|
-
</div><!-- description -->
|
148
233
|
|
234
|
+
<div id="instance_method_details" class="method_details_list">
|
235
|
+
<h2>Instance Method Details</h2>
|
236
|
+
|
237
|
+
|
238
|
+
<div class="method_details first">
|
239
|
+
<p class="signature first" id="bind-instance_method">
|
149
240
|
|
241
|
+
- (<tt>Object</tt>) <strong>bind</strong>(evid, handler)
|
150
242
|
|
243
|
+
|
151
244
|
|
152
|
-
|
153
|
-
|
245
|
+
</p><div class="docstring">
|
246
|
+
<div class="discussion">
|
247
|
+
<p>
|
248
|
+
Binds an event handler, which is a Hash of the form:
|
249
|
+
</p>
|
250
|
+
<p>
|
251
|
+
{ :evid => Symbol, :id => Symbol, :repeat => Boolean, :proc => Proc }
|
252
|
+
</p>
|
253
|
+
<p>
|
254
|
+
See on[rdoc-ref:Safubot::Evented#on] and
|
255
|
+
once[rdoc-ref:Safubot::Evented#once] for sugar.
|
256
|
+
</p>
|
154
257
|
|
155
|
-
|
156
258
|
|
157
|
-
|
259
|
+
</div>
|
260
|
+
</div>
|
261
|
+
<div class="tags">
|
262
|
+
|
158
263
|
|
264
|
+
</div><table class="source_code">
|
265
|
+
<tr>
|
266
|
+
<td>
|
267
|
+
<pre class="lines">
|
268
|
+
|
269
|
+
|
270
|
+
11
|
271
|
+
12
|
272
|
+
13
|
273
|
+
14
|
274
|
+
15
|
275
|
+
16
|
276
|
+
17</pre>
|
277
|
+
</td>
|
278
|
+
<td>
|
279
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/evented.rb', line 11</span>
|
280
|
+
|
281
|
+
<span class='kw'>def</span> <span class='id bind'>bind</span><span class='lparen'>(</span><span class='id evid'>evid</span><span class='comma'>,</span> <span class='id handler'>handler</span><span class='rparen'>)</span>
|
282
|
+
<span class='ivar'>@handlers</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
283
|
+
<span class='ivar'>@handlers</span><span class='lbracket'>[</span><span class='id evid'>evid</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
284
|
+
<span class='id handler'>handler</span><span class='lbracket'>[</span><span class='symbol'>:evid</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id evid'>evid</span>
|
285
|
+
<span class='id handler'>handler</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='ivar'>@handlers</span><span class='lbracket'>[</span><span class='id evid'>evid</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id length'>length</span>
|
286
|
+
<span class='ivar'>@handlers</span><span class='lbracket'>[</span><span class='id evid'>evid</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id handler'>handler</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id handler'>handler</span>
|
287
|
+
<span class='kw'>end</span></pre>
|
288
|
+
</td>
|
289
|
+
</tr>
|
290
|
+
</table>
|
291
|
+
</div>
|
159
292
|
|
293
|
+
<div class="method_details ">
|
294
|
+
<p class="signature " id="emit-instance_method">
|
295
|
+
|
296
|
+
- (<tt>Object</tt>) <strong>emit</strong>(evid, *args)
|
297
|
+
|
160
298
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
299
|
+
|
300
|
+
</p><div class="docstring">
|
301
|
+
<div class="discussion">
|
302
|
+
<p>
|
303
|
+
Fires an evid event with the given arguments.
|
304
|
+
</p>
|
165
305
|
|
166
|
-
|
167
|
-
<div id="method-i-bind" class="method-detail ">
|
168
|
-
|
169
|
-
<div class="method-heading">
|
170
|
-
<span class="method-name">bind</span><span
|
171
|
-
class="method-args">(evid, handler)</span>
|
172
|
-
<span class="method-click-advice">click to toggle source</span>
|
173
|
-
</div>
|
174
|
-
|
175
|
-
|
176
|
-
<div class="method-description">
|
177
|
-
|
178
|
-
<p>Binds an event handler, which is a Hash of the form:</p>
|
179
|
-
|
180
|
-
<pre class="ruby">{ :<span class="ruby-identifier">evid</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Symbol</span>, :<span class="ruby-identifier">id</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Symbol</span>, :<span class="ruby-identifier">repeat</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Boolean</span>, :<span class="ruby-identifier">proc</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Proc</span> }
|
181
|
-
</pre>
|
182
|
-
|
183
|
-
<p>See on and once for sugar.</p>
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
<div class="method-source-code" id="bind-source">
|
188
|
-
<pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 10</span>
|
189
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">bind</span>(<span class="ruby-identifier">evid</span>, <span class="ruby-identifier">handler</span>)
|
190
|
-
<span class="ruby-ivar">@handlers</span> <span class="ruby-operator">||=</span> {}
|
191
|
-
<span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>] <span class="ruby-operator">||=</span> {}
|
192
|
-
<span class="ruby-identifier">handler</span>[<span class="ruby-value">:evid</span>] = <span class="ruby-identifier">evid</span>
|
193
|
-
<span class="ruby-identifier">handler</span>[<span class="ruby-value">:id</span>] <span class="ruby-operator">||=</span> <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>].<span class="ruby-identifier">length</span>
|
194
|
-
<span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>][<span class="ruby-identifier">handler</span>[<span class="ruby-value">:id</span>]] = <span class="ruby-identifier">handler</span>
|
195
|
-
<span class="ruby-keyword">end</span></pre>
|
196
|
-
</div><!-- bind-source -->
|
197
|
-
|
198
|
-
</div>
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
</div><!-- bind-method -->
|
204
306
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
<span class="method-name">emit</span><span
|
210
|
-
class="method-args">(evid, *args)</span>
|
211
|
-
<span class="method-click-advice">click to toggle source</span>
|
212
|
-
</div>
|
213
|
-
|
214
|
-
|
215
|
-
<div class="method-description">
|
216
|
-
|
217
|
-
<p>Fires an evid event with the given arguments.</p>
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
<div class="method-source-code" id="emit-source">
|
222
|
-
<pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 36</span>
|
223
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">emit</span>(<span class="ruby-identifier">evid</span>, *<span class="ruby-identifier">args</span>)
|
224
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@handlers</span> <span class="ruby-operator">&&</span> <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>]
|
225
|
-
<span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>, <span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
|
226
|
-
<span class="ruby-keyword">begin</span>
|
227
|
-
<span class="ruby-identifier">handler</span>[<span class="ruby-value">:proc</span>].<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">args</span>)
|
228
|
-
<span class="ruby-keyword">ensure</span>
|
229
|
-
<span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">evid</span>].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">id</span>) <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">handler</span>[<span class="ruby-value">:repeat</span>]
|
230
|
-
<span class="ruby-keyword">end</span>
|
231
|
-
<span class="ruby-keyword">end</span>
|
232
|
-
<span class="ruby-keyword">end</span></pre>
|
233
|
-
</div><!-- emit-source -->
|
234
|
-
|
235
|
-
</div>
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
</div><!-- emit-method -->
|
307
|
+
</div>
|
308
|
+
</div>
|
309
|
+
<div class="tags">
|
310
|
+
|
241
311
|
|
312
|
+
</div><table class="source_code">
|
313
|
+
<tr>
|
314
|
+
<td>
|
315
|
+
<pre class="lines">
|
316
|
+
|
317
|
+
|
318
|
+
41
|
319
|
+
42
|
320
|
+
43
|
321
|
+
44
|
322
|
+
45
|
323
|
+
46
|
324
|
+
47
|
325
|
+
48
|
326
|
+
49
|
327
|
+
50</pre>
|
328
|
+
</td>
|
329
|
+
<td>
|
330
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/evented.rb', line 41</span>
|
331
|
+
|
332
|
+
<span class='kw'>def</span> <span class='id emit'>emit</span><span class='lparen'>(</span><span class='id evid'>evid</span><span class='comma'>,</span> <span class='op'>*</span><span class='id args'>args</span><span class='rparen'>)</span>
|
333
|
+
<span class='kw'>return</span> <span class='kw'>unless</span> <span class='ivar'>@handlers</span> <span class='op'>&&</span> <span class='ivar'>@handlers</span><span class='lbracket'>[</span><span class='id evid'>evid</span><span class='rbracket'>]</span>
|
334
|
+
<span class='ivar'>@handlers</span><span class='lbracket'>[</span><span class='id evid'>evid</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id id'>id</span><span class='comma'>,</span> <span class='id handler'>handler</span><span class='op'>|</span>
|
335
|
+
<span class='kw'>begin</span>
|
336
|
+
<span class='id handler'>handler</span><span class='lbracket'>[</span><span class='symbol'>:proc</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id call'>call</span><span class='lparen'>(</span><span class='op'>*</span><span class='id args'>args</span><span class='rparen'>)</span>
|
337
|
+
<span class='kw'>ensure</span>
|
338
|
+
<span class='ivar'>@handlers</span><span class='lbracket'>[</span><span class='id evid'>evid</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='id id'>id</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id handler'>handler</span><span class='lbracket'>[</span><span class='symbol'>:repeat</span><span class='rbracket'>]</span>
|
339
|
+
<span class='kw'>end</span>
|
340
|
+
<span class='kw'>end</span>
|
341
|
+
<span class='kw'>end</span></pre>
|
342
|
+
</td>
|
343
|
+
</tr>
|
344
|
+
</table>
|
345
|
+
</div>
|
242
346
|
|
243
|
-
<div
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
<div class="method-source-code" id="on-source">
|
259
|
-
<pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 25</span>
|
260
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">on</span>(<span class="ruby-identifier">evid</span>, <span class="ruby-identifier">opts</span>={}, &<span class="ruby-identifier">callback</span>)
|
261
|
-
<span class="ruby-identifier">bind</span>(<span class="ruby-identifier">evid</span>, { <span class="ruby-value">:repeat</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:proc</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">callback</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">opts</span>))
|
262
|
-
<span class="ruby-keyword">end</span></pre>
|
263
|
-
</div><!-- on-source -->
|
264
|
-
|
265
|
-
</div>
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
</div><!-- on-method -->
|
347
|
+
<div class="method_details ">
|
348
|
+
<p class="signature " id="on-instance_method">
|
349
|
+
|
350
|
+
- (<tt>Object</tt>) <strong>on</strong>(evid, opts = {}, &callback)
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
</p><div class="docstring">
|
355
|
+
<div class="discussion">
|
356
|
+
<p>
|
357
|
+
Binds a block to the specified event id. Returns the bound handler.
|
358
|
+
</p>
|
271
359
|
|
272
|
-
|
273
|
-
<div id="method-i-once" class="method-detail ">
|
274
|
-
|
275
|
-
<div class="method-heading">
|
276
|
-
<span class="method-name">once</span><span
|
277
|
-
class="method-args">(evid, opts={}, &callback)</span>
|
278
|
-
<span class="method-click-advice">click to toggle source</span>
|
279
|
-
</div>
|
280
|
-
|
281
|
-
|
282
|
-
<div class="method-description">
|
283
|
-
|
284
|
-
<p>Binds a block to the specified event id, to be executed only once. Returns
|
285
|
-
the bound handler.</p>
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
<div class="method-source-code" id="once-source">
|
290
|
-
<pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 31</span>
|
291
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">once</span>(<span class="ruby-identifier">evid</span>, <span class="ruby-identifier">opts</span>={}, &<span class="ruby-identifier">callback</span>)
|
292
|
-
<span class="ruby-identifier">bind</span>(<span class="ruby-identifier">evid</span>, { <span class="ruby-value">:repeat</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">false</span>, <span class="ruby-value">:proc</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">callback</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">opts</span>))
|
293
|
-
<span class="ruby-keyword">end</span></pre>
|
294
|
-
</div><!-- once-source -->
|
295
|
-
|
296
|
-
</div>
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
</div><!-- once-method -->
|
302
360
|
|
361
|
+
</div>
|
362
|
+
</div>
|
363
|
+
<div class="tags">
|
364
|
+
|
365
|
+
|
366
|
+
</div><table class="source_code">
|
367
|
+
<tr>
|
368
|
+
<td>
|
369
|
+
<pre class="lines">
|
370
|
+
|
371
|
+
|
372
|
+
28
|
373
|
+
29
|
374
|
+
30</pre>
|
375
|
+
</td>
|
376
|
+
<td>
|
377
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/evented.rb', line 28</span>
|
378
|
+
|
379
|
+
<span class='kw'>def</span> <span class='id on'>on</span><span class='lparen'>(</span><span class='id evid'>evid</span><span class='comma'>,</span> <span class='id opts'>opts</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id callback'>callback</span><span class='rparen'>)</span>
|
380
|
+
<span class='id bind'>bind</span><span class='lparen'>(</span><span class='id evid'>evid</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:repeat</span> <span class='op'>=></span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:proc</span> <span class='op'>=></span> <span class='id callback'>callback</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id merge'>merge</span><span class='lparen'>(</span><span class='id opts'>opts</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
381
|
+
<span class='kw'>end</span></pre>
|
382
|
+
</td>
|
383
|
+
</tr>
|
384
|
+
</table>
|
385
|
+
</div>
|
303
386
|
|
304
|
-
<div
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<span class="method-click-advice">click to toggle source</span>
|
310
|
-
</div>
|
311
|
-
|
312
|
-
|
313
|
-
<div class="method-description">
|
314
|
-
|
315
|
-
<p>Unbinds the given handler.</p>
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
<div class="method-source-code" id="unbind-source">
|
320
|
-
<pre><span class="ruby-comment"># File lib/safubot/evented.rb, line 19</span>
|
321
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">unbind</span>(<span class="ruby-identifier">handler</span>)
|
322
|
-
<span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">handler</span>[<span class="ruby-value">:evid</span>]].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">handler</span>[<span class="ruby-value">:id</span>])
|
323
|
-
<span class="ruby-keyword">end</span></pre>
|
324
|
-
</div><!-- unbind-source -->
|
325
|
-
|
326
|
-
</div>
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
</div><!-- unbind-method -->
|
387
|
+
<div class="method_details ">
|
388
|
+
<p class="signature " id="once-instance_method">
|
389
|
+
|
390
|
+
- (<tt>Object</tt>) <strong>once</strong>(evid, opts = {}, &callback)
|
391
|
+
|
332
392
|
|
393
|
+
|
394
|
+
</p><div class="docstring">
|
395
|
+
<div class="discussion">
|
396
|
+
<p>
|
397
|
+
Binds a block to the specified event id, to be executed only once. Returns
|
398
|
+
the bound handler.
|
399
|
+
</p>
|
400
|
+
|
401
|
+
|
402
|
+
</div>
|
403
|
+
</div>
|
404
|
+
<div class="tags">
|
405
|
+
|
406
|
+
|
407
|
+
</div><table class="source_code">
|
408
|
+
<tr>
|
409
|
+
<td>
|
410
|
+
<pre class="lines">
|
411
|
+
|
412
|
+
|
413
|
+
35
|
414
|
+
36
|
415
|
+
37</pre>
|
416
|
+
</td>
|
417
|
+
<td>
|
418
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/evented.rb', line 35</span>
|
419
|
+
|
420
|
+
<span class='kw'>def</span> <span class='id once'>once</span><span class='lparen'>(</span><span class='id evid'>evid</span><span class='comma'>,</span> <span class='id opts'>opts</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id callback'>callback</span><span class='rparen'>)</span>
|
421
|
+
<span class='id bind'>bind</span><span class='lparen'>(</span><span class='id evid'>evid</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='symbol'>:repeat</span> <span class='op'>=></span> <span class='kw'>false</span><span class='comma'>,</span> <span class='symbol'>:proc</span> <span class='op'>=></span> <span class='id callback'>callback</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id merge'>merge</span><span class='lparen'>(</span><span class='id opts'>opts</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
422
|
+
<span class='kw'>end</span></pre>
|
423
|
+
</td>
|
424
|
+
</tr>
|
425
|
+
</table>
|
426
|
+
</div>
|
333
427
|
|
334
|
-
|
428
|
+
<div class="method_details ">
|
429
|
+
<p class="signature " id="unbind-instance_method">
|
430
|
+
|
431
|
+
- (<tt>Object</tt>) <strong>unbind</strong>(handler)
|
335
432
|
|
336
|
-
</section><!-- 5Buntitled-5D -->
|
337
433
|
|
338
|
-
|
434
|
+
|
435
|
+
</p><div class="docstring">
|
436
|
+
<div class="discussion">
|
437
|
+
<p>
|
438
|
+
Unbinds the given handler.
|
439
|
+
</p>
|
339
440
|
|
340
441
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
</footer>
|
442
|
+
</div>
|
443
|
+
</div>
|
444
|
+
<div class="tags">
|
445
|
+
|
346
446
|
|
447
|
+
</div><table class="source_code">
|
448
|
+
<tr>
|
449
|
+
<td>
|
450
|
+
<pre class="lines">
|
451
|
+
|
452
|
+
|
453
|
+
21
|
454
|
+
22
|
455
|
+
23</pre>
|
456
|
+
</td>
|
457
|
+
<td>
|
458
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/evented.rb', line 21</span>
|
459
|
+
|
460
|
+
<span class='kw'>def</span> <span class='id unbind'>unbind</span><span class='lparen'>(</span><span class='id handler'>handler</span><span class='rparen'>)</span>
|
461
|
+
<span class='ivar'>@handlers</span><span class='lbracket'>[</span><span class='id handler'>handler</span><span class='lbracket'>[</span><span class='symbol'>:evid</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='id handler'>handler</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
462
|
+
<span class='kw'>end</span></pre>
|
463
|
+
</td>
|
464
|
+
</tr>
|
465
|
+
</table>
|
466
|
+
</div>
|
467
|
+
|
468
|
+
</div>
|
469
|
+
|
470
|
+
</div>
|
471
|
+
|
472
|
+
<div id="footer">
|
473
|
+
Generated on Mon Nov 28 20:20:04 2011 by
|
474
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
475
|
+
0.7.3 (ruby-1.9.2).
|
476
|
+
</div>
|
477
|
+
|
478
|
+
</body>
|
479
|
+
</html>
|