libastag 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/BUGS +10 -0
- data/CHANGES +8 -1
- data/MIT-LICENSE +2 -1
- data/README +7 -3
- data/Rakefile +3 -2
- data/TODO +4 -7
- data/doc/classes/Helpers.html +16 -20
- data/doc/classes/Helpers/REXML.html +4 -4
- data/doc/classes/Helpers/REXML/Attributes.html +10 -10
- data/doc/classes/Libastag.html +5 -5
- data/doc/classes/Libastag/Rabbit.html +56 -56
- data/doc/classes/Libastag/RabitEar.html +4 -4
- data/doc/classes/Libastag/RabitLed.html +4 -4
- data/doc/classes/Request.html +33 -37
- data/doc/classes/Request/Action.html +34 -34
- data/doc/classes/Request/AudioStream.html +313 -0
- data/doc/classes/Request/Base.html +13 -10
- data/doc/classes/Request/Base/Event.html +58 -23
- data/doc/classes/Request/Base/EventCollection.html +35 -32
- data/doc/classes/Request/Choregraphy.html +500 -0
- data/doc/classes/Request/Choregraphy/BadChorDesc.html +135 -0
- data/doc/classes/Request/Choregraphy/Ears.html +130 -0
- data/doc/classes/Request/Choregraphy/Ears/Directions.html +141 -0
- data/doc/classes/Request/Choregraphy/Ears/Positions.html +146 -0
- data/doc/classes/Request/Choregraphy/Leds.html +130 -0
- data/doc/classes/Request/Choregraphy/Leds/Colors.html +171 -0
- data/doc/classes/Request/Choregraphy/Leds/Positions.html +161 -0
- data/doc/classes/Request/GET_EARS_POSITION.html +17 -14
- data/doc/classes/Request/IdMessage.html +234 -0
- data/doc/classes/Request/Query.html +80 -55
- data/doc/classes/Request/SetEarsPosition.html +58 -36
- data/doc/classes/Request/TtsMessage.html +74 -50
- data/doc/classes/Response.html +55 -124
- data/doc/classes/Response/AbuseSending.html +34 -34
- data/doc/classes/Response/Base.html +34 -34
- data/doc/classes/Response/Base/BadServerRsp.html +34 -34
- data/doc/classes/Response/Base/GoodServerRsp.html +34 -34
- data/doc/classes/Response/Base/ServerRsp.html +53 -53
- data/doc/classes/Response/Blacklist.html +34 -34
- data/doc/classes/Response/ChorNotSend.html +34 -34
- data/doc/classes/Response/ChorSend.html +34 -34
- data/doc/classes/Response/CommandSend.html +34 -34
- data/doc/classes/Response/EarPositionNotSend.html +34 -34
- data/doc/classes/Response/EarPositionSend.html +34 -34
- data/doc/classes/Response/EmptyServerRsp.html +34 -34
- data/doc/classes/Response/LangListUser.html +34 -34
- data/doc/classes/Response/LinkPreview.html +34 -34
- data/doc/classes/Response/ListFriend.html +34 -34
- data/doc/classes/Response/ListReceivedMsg.html +34 -34
- data/doc/classes/Response/MessageNotSend.html +34 -34
- data/doc/classes/Response/MessageSend.html +34 -34
- data/doc/classes/Response/NabCastNotSend.html +34 -34
- data/doc/classes/Response/NabCastSend.html +34 -34
- data/doc/classes/Response/NoCorrectParameters.html +34 -34
- data/doc/classes/Response/NoGoodTokenOrSerial.html +34 -34
- data/doc/classes/Response/NotV2Rabbit.html +34 -34
- data/doc/classes/Response/PositionEar.html +34 -34
- data/doc/classes/Response/ProtocolExcepion.html +35 -35
- data/doc/classes/Response/RabbitName.html +34 -34
- data/doc/classes/Response/RabbitSleep.html +34 -34
- data/doc/classes/Response/RabbitVersion.html +34 -34
- data/doc/classes/Response/Signature.html +34 -34
- data/doc/classes/Response/Timezone.html +34 -34
- data/doc/classes/Response/TtsNotSend.html +34 -34
- data/doc/classes/Response/TtsSend.html +34 -34
- data/doc/classes/Response/VoiceListTts.html +34 -34
- data/doc/classes/Response/WebRadioNotSend.html +34 -34
- data/doc/classes/Response/WebRadioSend.html +34 -34
- data/doc/created.rid +1 -1
- data/doc/dot/f_0.png +0 -0
- data/doc/dot/f_5.dot +13 -445
- data/doc/dot/f_5.png +0 -0
- data/doc/dot/f_6.dot +445 -11
- data/doc/dot/f_6.png +0 -0
- data/doc/dot/f_7.dot +30 -5
- data/doc/dot/f_7.png +0 -0
- data/doc/dot/f_8.dot +39 -0
- data/doc/dot/f_8.png +0 -0
- data/doc/files/{lib/violet/violetapi_rb.html → BUGS.html} +17 -9
- data/doc/files/CHANGES.html +15 -2
- data/doc/files/MIT-LICENSE.html +2 -2
- data/doc/files/README.html +13 -3
- data/doc/files/TODO.html +5 -8
- data/doc/files/lib/libastag_rb.html +12 -10
- data/doc/files/lib/violet/helpers_rb.html +5 -5
- data/doc/files/lib/violet/request_rb.html +16 -12
- data/doc/files/lib/violet/response_rb.html +36 -35
- data/doc/fr_class_index.html +10 -1
- data/doc/fr_file_index.html +1 -1
- data/doc/fr_method_index.html +25 -12
- data/examples/morse.rb +72 -0
- data/lib/libastag.rb +6 -2
- data/lib/violet/helpers.rb +4 -2
- data/lib/violet/request.rb +501 -47
- data/lib/violet/response.rb +5 -2
- data/test/fake_violet_srv.rb +1 -1
- data/test/test_helpers.rb +3 -5
- data/test/{test_send.rb → test_query_and_actions.rb} +27 -10
- data/test/test_request_base.rb +76 -0
- data/test/test_request_chor.rb +162 -0
- data/test/test_request_stuff.rb +171 -0
- data/test/test_response.rb +3 -4
- metadata +45 -20
- data/doc/classes/VioletAPI.html +0 -118
- data/doc/dot/f_4.dot +0 -57
- data/doc/dot/f_4.png +0 -0
- data/lib/violet/violetapi.rb +0 -14
- data/test/test_request.rb +0 -20
|
@@ -79,16 +79,19 @@
|
|
|
79
79
|
<div id="contextContent">
|
|
80
80
|
<div id="diagram">
|
|
81
81
|
<map id="map" name="map">
|
|
82
|
-
<area shape="rect" coords="
|
|
83
|
-
<area shape="rect" coords="27,
|
|
84
|
-
<area shape="rect" coords="123,
|
|
85
|
-
<area shape="rect" coords="
|
|
86
|
-
<area shape="rect" coords="
|
|
87
|
-
<area shape="rect" coords="
|
|
88
|
-
<area shape="rect" coords="
|
|
89
|
-
<area shape="rect" coords="
|
|
90
|
-
<area shape="rect" coords="
|
|
91
|
-
<area shape="rect" coords="
|
|
82
|
+
<area shape="rect" coords="736,86,808,134" href="Event.html" alt="Event" />
|
|
83
|
+
<area shape="rect" coords="27,182,99,230" href="../Action.html" alt="Action" />
|
|
84
|
+
<area shape="rect" coords="123,182,216,230" href="../AudioStream.html" alt="AudioStream" />
|
|
85
|
+
<area shape="rect" coords="240,182,333,230" href="../Choregraphy.html" alt="Choregraphy" />
|
|
86
|
+
<area shape="rect" coords="357,182,448,230" href="../TtsMessage.html" alt="TtsMessage" />
|
|
87
|
+
<area shape="rect" coords="472,182,555,230" href="../IdMessage.html" alt="IdMessage" />
|
|
88
|
+
<area shape="rect" coords="579,182,685,230" href="../SetEarsPosition.html" alt="SetEarsPosition" />
|
|
89
|
+
<area shape="rect" coords="709,182,813,230" href="EventCollection.html" alt="EventCollection" />
|
|
90
|
+
<area shape="rect" coords="984,86,1061,134" href="../../Enumerable.html" alt="Enumerable" />
|
|
91
|
+
<area shape="rect" coords="307,86,379,134" href="../Query.html" alt="Query" />
|
|
92
|
+
<area shape="rect" coords="835,74,963,122" href="../GET_EARS_POSITION.html" alt="GET_EARS_POSITION" />
|
|
93
|
+
<area shape="rect" coords="699,51,824,240" href="../Base.html" alt="Base" />
|
|
94
|
+
<area shape="rect" coords="16,16,973,251" href="../../Request.html" alt="Request" />
|
|
92
95
|
</map>
|
|
93
96
|
<img src="../../../dot/f_8.png" usemap="#map" border="0" alt="dot/f_8.png">
|
|
94
97
|
</div>
|
|
@@ -109,6 +112,7 @@ superclass of message send to Violet.
|
|
|
109
112
|
<div class="name-list">
|
|
110
113
|
<a href="#M000020">+</a>
|
|
111
114
|
<a href="#M000019">new</a>
|
|
115
|
+
<a href="#M000022">streamed?</a>
|
|
112
116
|
<a href="#M000021">to_url</a>
|
|
113
117
|
</div>
|
|
114
118
|
</div>
|
|
@@ -148,10 +152,10 @@ constructor has to be overrided
|
|
|
148
152
|
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
|
149
153
|
<div class="method-source-code" id="M000019-source">
|
|
150
154
|
<pre>
|
|
151
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 31</span>
|
|
156
|
+
31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
|
157
|
+
32: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>
|
|
158
|
+
33: <span class="ruby-keyword kw">end</span>
|
|
155
159
|
</pre>
|
|
156
160
|
</div>
|
|
157
161
|
</div>
|
|
@@ -170,16 +174,47 @@ constructor has to be overrided
|
|
|
170
174
|
|
|
171
175
|
<div class="method-description">
|
|
172
176
|
<p>
|
|
173
|
-
it‘s possible to send multiples events on a single request.
|
|
177
|
+
it‘s possible to send multiples events on a single request. this
|
|
178
|
+
method return a <a href="Event.html#M000019">new</a> <a
|
|
179
|
+
href="EventCollection.html">EventCollection</a> object, that cotains
|
|
180
|
+
<tt>self</tt> and <tt>other</tt>.
|
|
174
181
|
</p>
|
|
175
182
|
<p><a class="source-toggle" href="#"
|
|
176
183
|
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
|
177
184
|
<div class="method-source-code" id="M000020-source">
|
|
178
185
|
<pre>
|
|
179
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 37</span>
|
|
187
|
+
37: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">other</span>
|
|
188
|
+
38: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{other.inspect} is a Streamed Event"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">streamed?</span>
|
|
189
|
+
39: <span class="ruby-constant">EventCollection</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">other</span>
|
|
190
|
+
40: <span class="ruby-keyword kw">end</span>
|
|
191
|
+
</pre>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<div id="method-M000022" class="method-detail">
|
|
197
|
+
<a name="M000022"></a>
|
|
198
|
+
|
|
199
|
+
<div class="method-heading">
|
|
200
|
+
<a href="#M000022" class="method-signature">
|
|
201
|
+
<span class="method-name">streamed?</span><span class="method-args">()</span>
|
|
202
|
+
</a>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<div class="method-description">
|
|
206
|
+
<p>
|
|
207
|
+
return <tt>true</tt> if self is a Stream <a href="Event.html">Event</a>
|
|
208
|
+
(that use APISTREAM_URL instead of API_URL), <tt>false</tt> otherwise.
|
|
209
|
+
</p>
|
|
210
|
+
<p><a class="source-toggle" href="#"
|
|
211
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
|
212
|
+
<div class="method-source-code" id="M000022-source">
|
|
213
|
+
<pre>
|
|
214
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 48</span>
|
|
215
|
+
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">streamed?</span>
|
|
216
|
+
49: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/Stream$/</span>
|
|
217
|
+
50: <span class="ruby-keyword kw">end</span>
|
|
183
218
|
</pre>
|
|
184
219
|
</div>
|
|
185
220
|
</div>
|
|
@@ -202,10 +237,10 @@ it‘s possible to send multiples events on a single request.
|
|
|
202
237
|
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
|
203
238
|
<div class="method-source-code" id="M000021-source">
|
|
204
239
|
<pre>
|
|
205
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
240
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 43</span>
|
|
241
|
+
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_url</span>
|
|
242
|
+
44: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>
|
|
243
|
+
45: <span class="ruby-keyword kw">end</span>
|
|
209
244
|
</pre>
|
|
210
245
|
</div>
|
|
211
246
|
</div>
|
|
@@ -81,16 +81,19 @@
|
|
|
81
81
|
<div id="contextContent">
|
|
82
82
|
<div id="diagram">
|
|
83
83
|
<map id="map" name="map">
|
|
84
|
-
<area shape="rect" coords="
|
|
85
|
-
<area shape="rect" coords="27,
|
|
86
|
-
<area shape="rect" coords="123,
|
|
87
|
-
<area shape="rect" coords="
|
|
88
|
-
<area shape="rect" coords="
|
|
89
|
-
<area shape="rect" coords="
|
|
90
|
-
<area shape="rect" coords="
|
|
91
|
-
<area shape="rect" coords="
|
|
92
|
-
<area shape="rect" coords="
|
|
93
|
-
<area shape="rect" coords="
|
|
84
|
+
<area shape="rect" coords="736,86,808,134" href="Event.html" alt="Event" />
|
|
85
|
+
<area shape="rect" coords="27,182,99,230" href="../Action.html" alt="Action" />
|
|
86
|
+
<area shape="rect" coords="123,182,216,230" href="../AudioStream.html" alt="AudioStream" />
|
|
87
|
+
<area shape="rect" coords="240,182,333,230" href="../Choregraphy.html" alt="Choregraphy" />
|
|
88
|
+
<area shape="rect" coords="357,182,448,230" href="../TtsMessage.html" alt="TtsMessage" />
|
|
89
|
+
<area shape="rect" coords="472,182,555,230" href="../IdMessage.html" alt="IdMessage" />
|
|
90
|
+
<area shape="rect" coords="579,182,685,230" href="../SetEarsPosition.html" alt="SetEarsPosition" />
|
|
91
|
+
<area shape="rect" coords="709,182,813,230" href="EventCollection.html" alt="EventCollection" />
|
|
92
|
+
<area shape="rect" coords="984,86,1061,134" href="../../Enumerable.html" alt="Enumerable" />
|
|
93
|
+
<area shape="rect" coords="307,86,379,134" href="../Query.html" alt="Query" />
|
|
94
|
+
<area shape="rect" coords="835,74,963,122" href="../GET_EARS_POSITION.html" alt="GET_EARS_POSITION" />
|
|
95
|
+
<area shape="rect" coords="699,51,824,240" href="../Base.html" alt="Base" />
|
|
96
|
+
<area shape="rect" coords="16,16,973,251" href="../../Request.html" alt="Request" />
|
|
94
97
|
</map>
|
|
95
98
|
<img src="../../../dot/f_8.png" usemap="#map" border="0" alt="dot/f_8.png">
|
|
96
99
|
</div>
|
|
@@ -158,14 +161,14 @@ href="EventCollection.html">EventCollection</a> with two childrens.
|
|
|
158
161
|
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
|
159
162
|
<div class="method-source-code" id="M000016-source">
|
|
160
163
|
<pre>
|
|
161
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 59</span>
|
|
165
|
+
59: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">one</span>, <span class="ruby-identifier">another</span>
|
|
166
|
+
60: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">one</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_url</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">another</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_url</span>) <span class="ruby-comment cmt"># \_o< Coin !</span>
|
|
167
|
+
61: <span class="ruby-ivar">@childrens</span> = [ <span class="ruby-identifier">one</span>, <span class="ruby-identifier">another</span> ]
|
|
168
|
+
62: <span class="ruby-keyword kw">else</span>
|
|
169
|
+
63: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'bad parameters'</span>)
|
|
170
|
+
64: <span class="ruby-keyword kw">end</span>
|
|
171
|
+
65: <span class="ruby-keyword kw">end</span>
|
|
169
172
|
</pre>
|
|
170
173
|
</div>
|
|
171
174
|
</div>
|
|
@@ -190,16 +193,16 @@ needed by Enumerable module. usage should be obvious :)
|
|
|
190
193
|
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
|
191
194
|
<div class="method-source-code" id="M000017-source">
|
|
192
195
|
<pre>
|
|
193
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 69</span>
|
|
197
|
+
69: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
|
|
198
|
+
70: <span class="ruby-ivar">@childrens</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
|
199
|
+
71: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Enumerable</span>
|
|
200
|
+
72: <span class="ruby-identifier">e</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">i</span> }
|
|
201
|
+
73: <span class="ruby-keyword kw">else</span>
|
|
202
|
+
74: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">e</span>
|
|
203
|
+
75: <span class="ruby-keyword kw">end</span>
|
|
204
|
+
76: <span class="ruby-keyword kw">end</span>
|
|
205
|
+
77: <span class="ruby-keyword kw">end</span>
|
|
203
206
|
</pre>
|
|
204
207
|
</div>
|
|
205
208
|
</div>
|
|
@@ -222,10 +225,10 @@ override <a href="Event.html#M000021">Event#to_url</a>.
|
|
|
222
225
|
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
|
223
226
|
<div class="method-source-code" id="M000018-source">
|
|
224
227
|
<pre>
|
|
225
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
228
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 80</span>
|
|
229
|
+
80: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_url</span>
|
|
230
|
+
81: <span class="ruby-ivar">@childrens</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_url</span> }.<span class="ruby-identifier">flatten</span>
|
|
231
|
+
82: <span class="ruby-keyword kw">end</span>
|
|
229
232
|
</pre>
|
|
230
233
|
</div>
|
|
231
234
|
</div>
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: Request::Choregraphy</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Request::Choregraphy</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/violet/request_rb.html">
|
|
59
|
+
lib/violet/request.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
<a href="Base/Event.html">
|
|
69
|
+
Base::Event
|
|
70
|
+
</a>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</table>
|
|
74
|
+
</div>
|
|
75
|
+
<!-- banner header -->
|
|
76
|
+
|
|
77
|
+
<div id="bodyContent">
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<div id="contextContent">
|
|
82
|
+
<div id="diagram">
|
|
83
|
+
<map id="map" name="map">
|
|
84
|
+
<area shape="rect" coords="736,86,808,134" href="Base/Event.html" alt="Event" />
|
|
85
|
+
<area shape="rect" coords="27,182,99,230" href="Action.html" alt="Action" />
|
|
86
|
+
<area shape="rect" coords="123,182,216,230" href="AudioStream.html" alt="AudioStream" />
|
|
87
|
+
<area shape="rect" coords="240,182,333,230" href="Choregraphy.html" alt="Choregraphy" />
|
|
88
|
+
<area shape="rect" coords="357,182,448,230" href="TtsMessage.html" alt="TtsMessage" />
|
|
89
|
+
<area shape="rect" coords="472,182,555,230" href="IdMessage.html" alt="IdMessage" />
|
|
90
|
+
<area shape="rect" coords="579,182,685,230" href="SetEarsPosition.html" alt="SetEarsPosition" />
|
|
91
|
+
<area shape="rect" coords="709,182,813,230" href="Base/EventCollection.html" alt="EventCollection" />
|
|
92
|
+
<area shape="rect" coords="984,86,1061,134" href="../Enumerable.html" alt="Enumerable" />
|
|
93
|
+
<area shape="rect" coords="307,86,379,134" href="Query.html" alt="Query" />
|
|
94
|
+
<area shape="rect" coords="835,74,963,122" href="GET_EARS_POSITION.html" alt="GET_EARS_POSITION" />
|
|
95
|
+
<area shape="rect" coords="699,51,824,240" href="Base.html" alt="Base" />
|
|
96
|
+
<area shape="rect" coords="16,16,973,251" href="../Request.html" alt="Request" />
|
|
97
|
+
</map>
|
|
98
|
+
<img src="../../dot/f_8.png" usemap="#map" border="0" alt="dot/f_8.png">
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div id="description">
|
|
102
|
+
<h1><a href="Choregraphy.html">Choregraphy</a></h1>
|
|
103
|
+
<p>
|
|
104
|
+
<a href="Choregraphy.html">Choregraphy</a> in the Violet API looks like
|
|
105
|
+
binary CSV code. It isn‘t really "user-friendly". We use a
|
|
106
|
+
DSL (Domain Specific Language) to describe <a
|
|
107
|
+
href="Choregraphy.html">Choregraphy</a> more easily, and then translate it
|
|
108
|
+
in with this class. This allows us to create a more powerful language,
|
|
109
|
+
making easy (for examples) to <a href="Choregraphy.html#M000033">set</a>
|
|
110
|
+
all leds in one sentence, instead of five 90% redundant lines :
|
|
111
|
+
</p>
|
|
112
|
+
<p>
|
|
113
|
+
‘<a href="Choregraphy.html#M000033">set</a> all to green’ will
|
|
114
|
+
we translated into
|
|
115
|
+
‘chor=10,0,led,0,0,255,0,0,led,1,0,255,0,0,led,2,0,255,0,0,led,3,0,255,0,0,led,4,0,255,0‘
|
|
116
|
+
</p>
|
|
117
|
+
<p>
|
|
118
|
+
Moreover, if you think that a <a href="Choregraphy.html">Choregraphy</a> is
|
|
119
|
+
a Set of Events (that are either an ear command either a led command), then
|
|
120
|
+
we can use logic operations such as ==, +, -, | and & on <a
|
|
121
|
+
href="Choregraphy.html">Choregraphy</a> (code taken from test file
|
|
122
|
+
test_request_chor.rb):
|
|
123
|
+
</p>
|
|
124
|
+
<pre>
|
|
125
|
+
one = Choregraphy.new { move left ear forward of degrees 42 }
|
|
126
|
+
two = Choregraphy.new { move right ear forward of degrees 42 }
|
|
127
|
+
onetwo = Choregraphy.new { move both ears forward of degrees 42 }
|
|
128
|
+
|
|
129
|
+
assert_equal one | two, one + two
|
|
130
|
+
assert_equal one & two, Choregraphy.new
|
|
131
|
+
assert_equal one - two, one
|
|
132
|
+
assert_equal two - one, two
|
|
133
|
+
assert_equal onetwo, one + two
|
|
134
|
+
assert_equal onetwo & two, two
|
|
135
|
+
assert_equal onetwo & one, one
|
|
136
|
+
assert_equal onetwo - two, one
|
|
137
|
+
assert_equal onetwo - one, two
|
|
138
|
+
assert_equal onetwo | two, onetwo
|
|
139
|
+
assert_equal onetwo | one, onetwo
|
|
140
|
+
</pre>
|
|
141
|
+
<h1><a href="Choregraphy.html">Choregraphy</a> Creation</h1>
|
|
142
|
+
<p>
|
|
143
|
+
see <a href="Choregraphy.html#M000029">new</a>
|
|
144
|
+
</p>
|
|
145
|
+
<h1><a href="Choregraphy.html">Choregraphy</a> DSL description</h1>
|
|
146
|
+
<p>
|
|
147
|
+
Here is the syntax description: [] are alternation with | or range with -
|
|
148
|
+
and <> are optionals.
|
|
149
|
+
</p>
|
|
150
|
+
<pre>
|
|
151
|
+
at time 1.2 <do>
|
|
152
|
+
move [right|left|both] <ear|ears> [backward|forward] <of> degrees [0-180]
|
|
153
|
+
set [bottom|left|middle|right|top|all] <led|leds> to [off|red|green|blue|yellow|magenta|cyan|white|rgb([0-255],[0-255],[0-255])]
|
|
154
|
+
<end>
|
|
155
|
+
</pre>
|
|
156
|
+
<h1>Examples</h1>
|
|
157
|
+
<p>
|
|
158
|
+
for examples, please see the test file (namely test_request_chor.rb),
|
|
159
|
+
because there are a lot of possible chor description and I don‘t want
|
|
160
|
+
to duplicate too much code :)
|
|
161
|
+
</p>
|
|
162
|
+
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<div id="method-list">
|
|
169
|
+
<h3 class="section-bar">Methods</h3>
|
|
170
|
+
|
|
171
|
+
<div class="name-list">
|
|
172
|
+
<a href="#M000032">==</a>
|
|
173
|
+
<a href="#M000031">bubble</a>
|
|
174
|
+
<a href="#M000034">move</a>
|
|
175
|
+
<a href="#M000029">new</a>
|
|
176
|
+
<a href="#M000033">set</a>
|
|
177
|
+
<a href="#M000030">to_url</a>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
<!-- if includes -->
|
|
185
|
+
|
|
186
|
+
<div id="section">
|
|
187
|
+
|
|
188
|
+
<div id="class-list">
|
|
189
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
|
190
|
+
|
|
191
|
+
Module <a href="Choregraphy/Ears.html" class="link">Request::Choregraphy::Ears</a><br />
|
|
192
|
+
Module <a href="Choregraphy/Leds.html" class="link">Request::Choregraphy::Leds</a><br />
|
|
193
|
+
Class <a href="Choregraphy/BadChorDesc.html" class="link">Request::Choregraphy::BadChorDesc</a><br />
|
|
194
|
+
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div id="constants-list">
|
|
198
|
+
<h3 class="section-bar">Constants</h3>
|
|
199
|
+
|
|
200
|
+
<div class="name-list">
|
|
201
|
+
<table summary="Constants">
|
|
202
|
+
<tr class="top-aligned-row context-row">
|
|
203
|
+
<td class="context-item-name">EarCommandStruct</td>
|
|
204
|
+
<td>=</td>
|
|
205
|
+
<td class="context-item-value">Struct.new :element, :direction, :angle, :time</td>
|
|
206
|
+
<td width="3em"> </td>
|
|
207
|
+
<td class="context-item-desc">
|
|
208
|
+
Command Structs for ears
|
|
209
|
+
|
|
210
|
+
</td>
|
|
211
|
+
</tr>
|
|
212
|
+
<tr class="top-aligned-row context-row">
|
|
213
|
+
<td class="context-item-name">LedCommandStruct</td>
|
|
214
|
+
<td>=</td>
|
|
215
|
+
<td class="context-item-value">Struct.new :elements, :color, :time</td>
|
|
216
|
+
<td width="3em"> </td>
|
|
217
|
+
<td class="context-item-desc">
|
|
218
|
+
Command Structs for leds
|
|
219
|
+
|
|
220
|
+
</td>
|
|
221
|
+
</tr>
|
|
222
|
+
</table>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
<div id="attribute-list">
|
|
229
|
+
<h3 class="section-bar">Attributes</h3>
|
|
230
|
+
|
|
231
|
+
<div class="name-list">
|
|
232
|
+
<table>
|
|
233
|
+
<tr class="top-aligned-row context-row">
|
|
234
|
+
<td class="context-item-name">chor</td>
|
|
235
|
+
<td class="context-item-value"> [R] </td>
|
|
236
|
+
<td class="context-item-desc">
|
|
237
|
+
used by operators == + - & |
|
|
238
|
+
|
|
239
|
+
</td>
|
|
240
|
+
</tr>
|
|
241
|
+
</table>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
<!-- if method_list -->
|
|
248
|
+
<div id="methods">
|
|
249
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
250
|
+
|
|
251
|
+
<div id="method-M000031" class="method-detail">
|
|
252
|
+
<a name="M000031"></a>
|
|
253
|
+
|
|
254
|
+
<div class="method-heading">
|
|
255
|
+
<a href="#M000031" class="method-signature">
|
|
256
|
+
<span class="method-name">bubble</span><span class="method-args">(*methods)</span>
|
|
257
|
+
</a>
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
<div class="method-description">
|
|
261
|
+
<p>
|
|
262
|
+
define dummy methods for DSL
|
|
263
|
+
</p>
|
|
264
|
+
<p><a class="source-toggle" href="#"
|
|
265
|
+
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
|
266
|
+
<div class="method-source-code" id="M000031-source">
|
|
267
|
+
<pre>
|
|
268
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 380</span>
|
|
269
|
+
380: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bubble</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">methods</span>)
|
|
270
|
+
381: <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span>
|
|
271
|
+
382: <span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">m</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span> <span class="ruby-identifier">args</span> }
|
|
272
|
+
383: <span class="ruby-identifier">private</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">to_sym</span>)
|
|
273
|
+
384: <span class="ruby-keyword kw">end</span>
|
|
274
|
+
385: <span class="ruby-keyword kw">end</span>
|
|
275
|
+
</pre>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
<div id="method-M000029" class="method-detail">
|
|
281
|
+
<a name="M000029"></a>
|
|
282
|
+
|
|
283
|
+
<div class="method-heading">
|
|
284
|
+
<a href="#M000029" class="method-signature">
|
|
285
|
+
<span class="method-name">new</span><span class="method-args">(h=Hash.new, &block)</span>
|
|
286
|
+
</a>
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
<div class="method-description">
|
|
290
|
+
<p>
|
|
291
|
+
Take some <a href="Choregraphy.html">Choregraphy</a> DSL code and translate
|
|
292
|
+
it into a <a href="Choregraphy.html">Choregraphy</a> description of Violet
|
|
293
|
+
API.
|
|
294
|
+
</p>
|
|
295
|
+
<h2>Arguments</h2>
|
|
296
|
+
<p>
|
|
297
|
+
(optionals) an Hash in argument with keys:
|
|
298
|
+
</p>
|
|
299
|
+
<dl>
|
|
300
|
+
<dt>name</dt><dd>the chortitle
|
|
301
|
+
|
|
302
|
+
</dd>
|
|
303
|
+
<dt>code</dt><dd>an array of String/Proc or a String/Proc that describe the <a
|
|
304
|
+
href="Choregraphy.html">Choregraphy</a> in our DSL.
|
|
305
|
+
|
|
306
|
+
</dd>
|
|
307
|
+
</dl>
|
|
308
|
+
<p>
|
|
309
|
+
(optionals) a block of code that describe the <a
|
|
310
|
+
href="Choregraphy.html">Choregraphy</a>.
|
|
311
|
+
</p>
|
|
312
|
+
<h2>Raise</h2>
|
|
313
|
+
<p>
|
|
314
|
+
raise a <a href="Choregraphy/BadChorDesc.html">Choregraphy::BadChorDesc</a>
|
|
315
|
+
if not happy.
|
|
316
|
+
</p>
|
|
317
|
+
<h2>Examples (all results are equals)</h2>
|
|
318
|
+
<pre>
|
|
319
|
+
Request::Choregraphy.new { set all off; move right ear forward of degrees 180 } # => #<Request::Choregraphy:0x2b07a05f8ca0 @chor=["0,led,0,0,0,0", "0,led,1,0,0,0", "0,led,2,0,0,0", "0,led,3,0,0,0", "0,led,4,0,0,0", "0,motor,0,180,0,0"], @code=[#<Proc:0x00002b07a05f8d40@(irb):3>], @time=0>
|
|
320
|
+
Request::Choregraphy.new :code => 'set all off; move right ear forward of degrees 180' # => #<Request::Choregraphy:0x2b07a05e84b8 @chor=["0,led,0,0,0,0", "0,led,1,0,0,0", "0,led,2,0,0,0", "0,led,3,0,0,0", "0,led,4,0,0,0", "0,motor,0,180,0,0"], @code=["set all off; move right ear forward of degrees 180"], @time=0>
|
|
321
|
+
Request::Choregraphy.new :code => [ 'set all off', 'move right ear forward of degrees 180' ] # => #<Request::Choregraphy:0x2b07a05dae30 @chor=["0,led,0,0,0,0", "0,led,1,0,0,0", "0,led,2,0,0,0", "0,led,3,0,0,0", "0,led,4,0,0,0", "0,motor,0,180,0,0"], @code=["set all off", "move right ear forward of degrees 180"], @time=0>
|
|
322
|
+
</pre>
|
|
323
|
+
<p><a class="source-toggle" href="#"
|
|
324
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
|
325
|
+
<div class="method-source-code" id="M000029-source">
|
|
326
|
+
<pre>
|
|
327
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 363</span>
|
|
328
|
+
363: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">h</span>=<span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
329
|
+
364: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:name</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:name</span>]
|
|
330
|
+
365: <span class="ruby-ivar">@code</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:code</span>] <span class="ruby-keyword kw">end</span>
|
|
331
|
+
366: <span class="ruby-identifier">__choreval__</span>
|
|
332
|
+
367: <span class="ruby-ivar">@chor</span>.<span class="ruby-identifier">sort!</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@chor</span>.<span class="ruby-identifier">nil?</span>
|
|
333
|
+
368: <span class="ruby-keyword kw">end</span>
|
|
334
|
+
</pre>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
340
|
+
|
|
341
|
+
<div id="method-M000032" class="method-detail">
|
|
342
|
+
<a name="M000032"></a>
|
|
343
|
+
|
|
344
|
+
<div class="method-heading">
|
|
345
|
+
<a href="#M000032" class="method-signature">
|
|
346
|
+
<span class="method-name">==</span><span class="method-args">(other)</span>
|
|
347
|
+
</a>
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
<div class="method-description">
|
|
351
|
+
<p><a class="source-toggle" href="#"
|
|
352
|
+
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
|
353
|
+
<div class="method-source-code" id="M000032-source">
|
|
354
|
+
<pre>
|
|
355
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 400</span>
|
|
356
|
+
400: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>
|
|
357
|
+
401: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">chor</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">chor</span>
|
|
358
|
+
402: <span class="ruby-keyword kw">end</span>
|
|
359
|
+
</pre>
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
362
|
+
</div>
|
|
363
|
+
|
|
364
|
+
<div id="method-M000034" class="method-detail">
|
|
365
|
+
<a name="M000034"></a>
|
|
366
|
+
|
|
367
|
+
<div class="method-heading">
|
|
368
|
+
<a href="#M000034" class="method-signature">
|
|
369
|
+
<span class="method-name">move</span><span class="method-args">(command)</span>
|
|
370
|
+
</a>
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
<div class="method-description">
|
|
374
|
+
<p><a class="source-toggle" href="#"
|
|
375
|
+
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
|
376
|
+
<div class="method-source-code" id="M000034-source">
|
|
377
|
+
<pre>
|
|
378
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 438</span>
|
|
379
|
+
438: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">move</span> <span class="ruby-identifier">command</span>
|
|
380
|
+
439: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'wrong Choregraphy description'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">EarCommandStruct</span>)
|
|
381
|
+
440: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'need a time'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>
|
|
382
|
+
441: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'time must be >= zero'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">>=</span> <span class="ruby-value">0</span>
|
|
383
|
+
442: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'need an angle'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">angle</span>
|
|
384
|
+
443: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'angle must be between 0 and 180'</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">180</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">command</span>.<span class="ruby-identifier">angle</span>)
|
|
385
|
+
444: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'need a direction'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">direction</span>
|
|
386
|
+
445: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'wrong direction'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">direction</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-constant">Ears</span><span class="ruby-operator">::</span><span class="ruby-constant">Directions</span><span class="ruby-operator">::</span><span class="ruby-constant">FORWARD</span>,<span class="ruby-constant">Ears</span><span class="ruby-operator">::</span><span class="ruby-constant">Directions</span><span class="ruby-operator">::</span><span class="ruby-constant">BACKWARD</span>)
|
|
387
|
+
446: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'need an element'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">element</span>
|
|
388
|
+
447: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'wrong element'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">element</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:both</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">element</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-constant">Ears</span><span class="ruby-operator">::</span><span class="ruby-constant">Positions</span><span class="ruby-operator">::</span><span class="ruby-constant">RIGHT</span>,<span class="ruby-constant">Ears</span><span class="ruby-operator">::</span><span class="ruby-constant">Positions</span><span class="ruby-operator">::</span><span class="ruby-constant">LEFT</span>)
|
|
389
|
+
448:
|
|
390
|
+
449: <span class="ruby-identifier">template</span> = <span class="ruby-value str">'%s,motor,%s,%s,0,%s'</span>
|
|
391
|
+
450:
|
|
392
|
+
451: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">element</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:both</span>
|
|
393
|
+
452: <span class="ruby-comment cmt"># we don't know, maybe your rabbit has more than two ears :)</span>
|
|
394
|
+
453: (<span class="ruby-constant">Ears</span><span class="ruby-operator">::</span><span class="ruby-constant">Positions</span>.<span class="ruby-identifier">constants</span> <span class="ruby-operator">-</span> [<span class="ruby-value str">'BOTH'</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cste_name</span><span class="ruby-operator">|</span>
|
|
395
|
+
454: <span class="ruby-identifier">cste</span> = <span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">constantize</span> <span class="ruby-node">"#{self.class}::Ears::Positions::#{cste_name}"</span>
|
|
396
|
+
455: <span class="ruby-ivar">@chor</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">template</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">cste</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">angle</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">direction</span> ]
|
|
397
|
+
456: <span class="ruby-keyword kw">end</span>
|
|
398
|
+
457: <span class="ruby-keyword kw">else</span>
|
|
399
|
+
458: <span class="ruby-ivar">@chor</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">template</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">element</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">angle</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">direction</span> ]
|
|
400
|
+
459: <span class="ruby-keyword kw">end</span>
|
|
401
|
+
460: <span class="ruby-keyword kw">end</span>
|
|
402
|
+
</pre>
|
|
403
|
+
</div>
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
|
|
407
|
+
<div id="method-M000033" class="method-detail">
|
|
408
|
+
<a name="M000033"></a>
|
|
409
|
+
|
|
410
|
+
<div class="method-heading">
|
|
411
|
+
<a href="#M000033" class="method-signature">
|
|
412
|
+
<span class="method-name">set</span><span class="method-args">(command)</span>
|
|
413
|
+
</a>
|
|
414
|
+
</div>
|
|
415
|
+
|
|
416
|
+
<div class="method-description">
|
|
417
|
+
<p><a class="source-toggle" href="#"
|
|
418
|
+
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
|
419
|
+
<div class="method-source-code" id="M000033-source">
|
|
420
|
+
<pre>
|
|
421
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 404</span>
|
|
422
|
+
404: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span> <span class="ruby-identifier">command</span>
|
|
423
|
+
405: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'wrong Choregraphy description'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">LedCommandStruct</span>)
|
|
424
|
+
406: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'need an element'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">elements</span>
|
|
425
|
+
407: <span class="ruby-identifier">command</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
|
426
|
+
408: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'wrong element'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:all</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-constant">Leds</span><span class="ruby-operator">::</span><span class="ruby-constant">Positions</span><span class="ruby-operator">::</span><span class="ruby-constant">BOTTOM</span>,<span class="ruby-constant">Leds</span><span class="ruby-operator">::</span><span class="ruby-constant">Positions</span><span class="ruby-operator">::</span><span class="ruby-constant">TOP</span>)
|
|
427
|
+
409: <span class="ruby-keyword kw">end</span>
|
|
428
|
+
410: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'need a time'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>
|
|
429
|
+
411: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'time must be >= than zero'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">>=</span> <span class="ruby-value">0</span>
|
|
430
|
+
412: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'need a color'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">color</span>
|
|
431
|
+
413: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'wrong size for rgb color array'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">color</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">3</span>
|
|
432
|
+
414: <span class="ruby-identifier">command</span>.<span class="ruby-identifier">color</span>.<span class="ruby-identifier">collect!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
|
|
433
|
+
415: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'color code must be betwen 0 and 255'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-value">0</span>,<span class="ruby-value">255</span>)
|
|
434
|
+
416: <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_i</span>
|
|
435
|
+
417: <span class="ruby-keyword kw">end</span>
|
|
436
|
+
418:
|
|
437
|
+
419: <span class="ruby-identifier">template</span> = <span class="ruby-value str">'%s,led,%s,%s'</span>
|
|
438
|
+
420: <span class="ruby-identifier">command</span>.<span class="ruby-identifier">color</span> = <span class="ruby-identifier">command</span>.<span class="ruby-identifier">color</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>)
|
|
439
|
+
421:
|
|
440
|
+
422: <span class="ruby-comment cmt"># remove trailling element if all is set</span>
|
|
441
|
+
423: <span class="ruby-identifier">command</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">uniq!</span>
|
|
442
|
+
424: <span class="ruby-identifier">command</span>.<span class="ruby-identifier">elements</span> = [<span class="ruby-identifier">:all</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:all</span>)
|
|
443
|
+
425:
|
|
444
|
+
426: <span class="ruby-identifier">command</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
|
445
|
+
427: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:all</span>
|
|
446
|
+
428: (<span class="ruby-constant">Leds</span><span class="ruby-operator">::</span><span class="ruby-constant">Positions</span>.<span class="ruby-identifier">constants</span> <span class="ruby-operator">-</span> [<span class="ruby-value str">'ALL'</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cste_name</span><span class="ruby-operator">|</span>
|
|
447
|
+
429: <span class="ruby-identifier">cste</span> = <span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">constantize</span> <span class="ruby-node">"#{self.class}::Leds::Positions::#{cste_name}"</span>
|
|
448
|
+
430: <span class="ruby-ivar">@chor</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">template</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">cste</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">color</span> ]
|
|
449
|
+
431: <span class="ruby-keyword kw">end</span>
|
|
450
|
+
432: <span class="ruby-keyword kw">else</span>
|
|
451
|
+
433: <span class="ruby-ivar">@chor</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">template</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">command</span>.<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">e</span>, <span class="ruby-identifier">command</span>.<span class="ruby-identifier">color</span> ]
|
|
452
|
+
434: <span class="ruby-keyword kw">end</span>
|
|
453
|
+
435: <span class="ruby-keyword kw">end</span>
|
|
454
|
+
436: <span class="ruby-keyword kw">end</span>
|
|
455
|
+
</pre>
|
|
456
|
+
</div>
|
|
457
|
+
</div>
|
|
458
|
+
</div>
|
|
459
|
+
|
|
460
|
+
<div id="method-M000030" class="method-detail">
|
|
461
|
+
<a name="M000030"></a>
|
|
462
|
+
|
|
463
|
+
<div class="method-heading">
|
|
464
|
+
<a href="#M000030" class="method-signature">
|
|
465
|
+
<span class="method-name">to_url</span><span class="method-args">()</span>
|
|
466
|
+
</a>
|
|
467
|
+
</div>
|
|
468
|
+
|
|
469
|
+
<div class="method-description">
|
|
470
|
+
<p><a class="source-toggle" href="#"
|
|
471
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
|
472
|
+
<div class="method-source-code" id="M000030-source">
|
|
473
|
+
<pre>
|
|
474
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 370</span>
|
|
475
|
+
370: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_url</span>
|
|
476
|
+
371: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadChorDesc</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'no choregraphy given'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@chor</span>
|
|
477
|
+
372:
|
|
478
|
+
373: <span class="ruby-identifier">url</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
|
479
|
+
374: <span class="ruby-identifier">url</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"chor=10,"</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@chor</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@chor</span>.<span class="ruby-identifier">nil?</span>
|
|
480
|
+
375: <span class="ruby-identifier">url</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"chortitle=#{@name}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@name</span>.<span class="ruby-identifier">nil?</span>
|
|
481
|
+
376: <span class="ruby-identifier">url</span>
|
|
482
|
+
377: <span class="ruby-keyword kw">end</span>
|
|
483
|
+
</pre>
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
</div>
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
</div>
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
</div>
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
<div id="validator-badges">
|
|
496
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
497
|
+
</div>
|
|
498
|
+
|
|
499
|
+
</body>
|
|
500
|
+
</html>
|