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.
Files changed (108) hide show
  1. data/BUGS +10 -0
  2. data/CHANGES +8 -1
  3. data/MIT-LICENSE +2 -1
  4. data/README +7 -3
  5. data/Rakefile +3 -2
  6. data/TODO +4 -7
  7. data/doc/classes/Helpers.html +16 -20
  8. data/doc/classes/Helpers/REXML.html +4 -4
  9. data/doc/classes/Helpers/REXML/Attributes.html +10 -10
  10. data/doc/classes/Libastag.html +5 -5
  11. data/doc/classes/Libastag/Rabbit.html +56 -56
  12. data/doc/classes/Libastag/RabitEar.html +4 -4
  13. data/doc/classes/Libastag/RabitLed.html +4 -4
  14. data/doc/classes/Request.html +33 -37
  15. data/doc/classes/Request/Action.html +34 -34
  16. data/doc/classes/Request/AudioStream.html +313 -0
  17. data/doc/classes/Request/Base.html +13 -10
  18. data/doc/classes/Request/Base/Event.html +58 -23
  19. data/doc/classes/Request/Base/EventCollection.html +35 -32
  20. data/doc/classes/Request/Choregraphy.html +500 -0
  21. data/doc/classes/Request/Choregraphy/BadChorDesc.html +135 -0
  22. data/doc/classes/Request/Choregraphy/Ears.html +130 -0
  23. data/doc/classes/Request/Choregraphy/Ears/Directions.html +141 -0
  24. data/doc/classes/Request/Choregraphy/Ears/Positions.html +146 -0
  25. data/doc/classes/Request/Choregraphy/Leds.html +130 -0
  26. data/doc/classes/Request/Choregraphy/Leds/Colors.html +171 -0
  27. data/doc/classes/Request/Choregraphy/Leds/Positions.html +161 -0
  28. data/doc/classes/Request/GET_EARS_POSITION.html +17 -14
  29. data/doc/classes/Request/IdMessage.html +234 -0
  30. data/doc/classes/Request/Query.html +80 -55
  31. data/doc/classes/Request/SetEarsPosition.html +58 -36
  32. data/doc/classes/Request/TtsMessage.html +74 -50
  33. data/doc/classes/Response.html +55 -124
  34. data/doc/classes/Response/AbuseSending.html +34 -34
  35. data/doc/classes/Response/Base.html +34 -34
  36. data/doc/classes/Response/Base/BadServerRsp.html +34 -34
  37. data/doc/classes/Response/Base/GoodServerRsp.html +34 -34
  38. data/doc/classes/Response/Base/ServerRsp.html +53 -53
  39. data/doc/classes/Response/Blacklist.html +34 -34
  40. data/doc/classes/Response/ChorNotSend.html +34 -34
  41. data/doc/classes/Response/ChorSend.html +34 -34
  42. data/doc/classes/Response/CommandSend.html +34 -34
  43. data/doc/classes/Response/EarPositionNotSend.html +34 -34
  44. data/doc/classes/Response/EarPositionSend.html +34 -34
  45. data/doc/classes/Response/EmptyServerRsp.html +34 -34
  46. data/doc/classes/Response/LangListUser.html +34 -34
  47. data/doc/classes/Response/LinkPreview.html +34 -34
  48. data/doc/classes/Response/ListFriend.html +34 -34
  49. data/doc/classes/Response/ListReceivedMsg.html +34 -34
  50. data/doc/classes/Response/MessageNotSend.html +34 -34
  51. data/doc/classes/Response/MessageSend.html +34 -34
  52. data/doc/classes/Response/NabCastNotSend.html +34 -34
  53. data/doc/classes/Response/NabCastSend.html +34 -34
  54. data/doc/classes/Response/NoCorrectParameters.html +34 -34
  55. data/doc/classes/Response/NoGoodTokenOrSerial.html +34 -34
  56. data/doc/classes/Response/NotV2Rabbit.html +34 -34
  57. data/doc/classes/Response/PositionEar.html +34 -34
  58. data/doc/classes/Response/ProtocolExcepion.html +35 -35
  59. data/doc/classes/Response/RabbitName.html +34 -34
  60. data/doc/classes/Response/RabbitSleep.html +34 -34
  61. data/doc/classes/Response/RabbitVersion.html +34 -34
  62. data/doc/classes/Response/Signature.html +34 -34
  63. data/doc/classes/Response/Timezone.html +34 -34
  64. data/doc/classes/Response/TtsNotSend.html +34 -34
  65. data/doc/classes/Response/TtsSend.html +34 -34
  66. data/doc/classes/Response/VoiceListTts.html +34 -34
  67. data/doc/classes/Response/WebRadioNotSend.html +34 -34
  68. data/doc/classes/Response/WebRadioSend.html +34 -34
  69. data/doc/created.rid +1 -1
  70. data/doc/dot/f_0.png +0 -0
  71. data/doc/dot/f_5.dot +13 -445
  72. data/doc/dot/f_5.png +0 -0
  73. data/doc/dot/f_6.dot +445 -11
  74. data/doc/dot/f_6.png +0 -0
  75. data/doc/dot/f_7.dot +30 -5
  76. data/doc/dot/f_7.png +0 -0
  77. data/doc/dot/f_8.dot +39 -0
  78. data/doc/dot/f_8.png +0 -0
  79. data/doc/files/{lib/violet/violetapi_rb.html → BUGS.html} +17 -9
  80. data/doc/files/CHANGES.html +15 -2
  81. data/doc/files/MIT-LICENSE.html +2 -2
  82. data/doc/files/README.html +13 -3
  83. data/doc/files/TODO.html +5 -8
  84. data/doc/files/lib/libastag_rb.html +12 -10
  85. data/doc/files/lib/violet/helpers_rb.html +5 -5
  86. data/doc/files/lib/violet/request_rb.html +16 -12
  87. data/doc/files/lib/violet/response_rb.html +36 -35
  88. data/doc/fr_class_index.html +10 -1
  89. data/doc/fr_file_index.html +1 -1
  90. data/doc/fr_method_index.html +25 -12
  91. data/examples/morse.rb +72 -0
  92. data/lib/libastag.rb +6 -2
  93. data/lib/violet/helpers.rb +4 -2
  94. data/lib/violet/request.rb +501 -47
  95. data/lib/violet/response.rb +5 -2
  96. data/test/fake_violet_srv.rb +1 -1
  97. data/test/test_helpers.rb +3 -5
  98. data/test/{test_send.rb → test_query_and_actions.rb} +27 -10
  99. data/test/test_request_base.rb +76 -0
  100. data/test/test_request_chor.rb +162 -0
  101. data/test/test_request_stuff.rb +171 -0
  102. data/test/test_response.rb +3 -4
  103. metadata +45 -20
  104. data/doc/classes/VioletAPI.html +0 -118
  105. data/doc/dot/f_4.dot +0 -57
  106. data/doc/dot/f_4.png +0 -0
  107. data/lib/violet/violetapi.rb +0 -14
  108. 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="392,85,464,133" href="Event.html" alt="Event" />
83
- <area shape="rect" coords="27,181,99,229" href="../Action.html" alt="Action" />
84
- <area shape="rect" coords="123,181,211,229" href="../TtsMessage.html" alt="TtsMessage" />
85
- <area shape="rect" coords="235,181,341,229" href="../SetEarsPosition.html" alt="SetEarsPosition" />
86
- <area shape="rect" coords="365,181,469,229" href="EventCollection.html" alt="EventCollection" />
87
- <area shape="rect" coords="647,85,724,133" href="../../Enumerable.html" alt="Enumerable" />
88
- <area shape="rect" coords="135,85,207,133" href="../Query.html" alt="Query" />
89
- <area shape="rect" coords="491,73,625,121" href="../GET_EARS_POSITION.html" alt="GET_EARS_POSITION" />
90
- <area shape="rect" coords="355,51,480,240" href="../Base.html" alt="Base" />
91
- <area shape="rect" coords="16,16,636,251" href="../../Request.html" alt="Request" />
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>&nbsp;&nbsp;
111
114
  <a href="#M000019">new</a>&nbsp;&nbsp;
115
+ <a href="#M000022">streamed?</a>&nbsp;&nbsp;
112
116
  <a href="#M000021">to_url</a>&nbsp;&nbsp;
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 26</span>
152
- 26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
153
- 27: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>
154
- 28: <span class="ruby-keyword kw">end</span>
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&#8216;s possible to send multiples events on a single request.
177
+ it&#8216;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 31</span>
180
- 31: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">other</span>
181
- 32: <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>
182
- 33: <span class="ruby-keyword kw">end</span>
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">&quot;#{other.inspect} is a Streamed Event&quot;</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&#8216;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 36</span>
206
- 36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_url</span>
207
- 37: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>
208
- 38: <span class="ruby-keyword kw">end</span>
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="392,85,464,133" href="Event.html" alt="Event" />
85
- <area shape="rect" coords="27,181,99,229" href="../Action.html" alt="Action" />
86
- <area shape="rect" coords="123,181,211,229" href="../TtsMessage.html" alt="TtsMessage" />
87
- <area shape="rect" coords="235,181,341,229" href="../SetEarsPosition.html" alt="SetEarsPosition" />
88
- <area shape="rect" coords="365,181,469,229" href="EventCollection.html" alt="EventCollection" />
89
- <area shape="rect" coords="647,85,724,133" href="../../Enumerable.html" alt="Enumerable" />
90
- <area shape="rect" coords="135,85,207,133" href="../Query.html" alt="Query" />
91
- <area shape="rect" coords="491,73,625,121" href="../GET_EARS_POSITION.html" alt="GET_EARS_POSITION" />
92
- <area shape="rect" coords="355,51,480,240" href="../Base.html" alt="Base" />
93
- <area shape="rect" coords="16,16,636,251" href="../../Request.html" alt="Request" />
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 47</span>
162
- 47: <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>
163
- 48: <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&lt; Coin !</span>
164
- 49: <span class="ruby-ivar">@childrens</span> = [ <span class="ruby-identifier">one</span>, <span class="ruby-identifier">another</span> ]
165
- 50: <span class="ruby-keyword kw">else</span>
166
- 51: <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>)
167
- 52: <span class="ruby-keyword kw">end</span>
168
- 53: <span class="ruby-keyword kw">end</span>
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&lt; 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 57</span>
194
- 57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
195
- 58: <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>
196
- 59: <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>
197
- 60: <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> }
198
- 61: <span class="ruby-keyword kw">else</span>
199
- 62: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">e</span>
200
- 63: <span class="ruby-keyword kw">end</span>
201
- 64: <span class="ruby-keyword kw">end</span>
202
- 65: <span class="ruby-keyword kw">end</span>
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 68</span>
226
- 68: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_url</span>
227
- 69: <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">join</span>(<span class="ruby-value str">'&amp;'</span>)
228
- 70: <span class="ruby-keyword kw">end</span>
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&#8216;t really &quot;user-friendly&quot;. 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
+ &#8216;<a href="Choregraphy.html#M000033">set</a> all to green&#8217; will
114
+ we translated into
115
+ &#8216;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&#8216;
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 &amp; 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 &amp; 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 &amp; two, two
135
+ assert_equal onetwo &amp; 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 &lt;&gt; are optionals.
149
+ </p>
150
+ <pre>
151
+ at time 1.2 &lt;do&gt;
152
+ move [right|left|both] &lt;ear|ears&gt; [backward|forward] &lt;of&gt; degrees [0-180]
153
+ set [bottom|left|middle|right|top|all] &lt;led|leds&gt; to [off|red|green|blue|yellow|magenta|cyan|white|rgb([0-255],[0-255],[0-255])]
154
+ &lt;end&gt;
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&#8216;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>&nbsp;&nbsp;
173
+ <a href="#M000031">bubble</a>&nbsp;&nbsp;
174
+ <a href="#M000034">move</a>&nbsp;&nbsp;
175
+ <a href="#M000029">new</a>&nbsp;&nbsp;
176
+ <a href="#M000033">set</a>&nbsp;&nbsp;
177
+ <a href="#M000030">to_url</a>&nbsp;&nbsp;
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">&nbsp;</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">&nbsp;</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">&nbsp;[R]&nbsp;</td>
236
+ <td class="context-item-desc">
237
+ used by operators == + - &amp; |
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, &amp;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 } # =&gt; #&lt;Request::Choregraphy:0x2b07a05f8ca0 @chor=[&quot;0,led,0,0,0,0&quot;, &quot;0,led,1,0,0,0&quot;, &quot;0,led,2,0,0,0&quot;, &quot;0,led,3,0,0,0&quot;, &quot;0,led,4,0,0,0&quot;, &quot;0,motor,0,180,0,0&quot;], @code=[#&lt;Proc:0x00002b07a05f8d40@(irb):3&gt;], @time=0&gt;
320
+ Request::Choregraphy.new :code =&gt; 'set all off; move right ear forward of degrees 180' # =&gt; #&lt;Request::Choregraphy:0x2b07a05e84b8 @chor=[&quot;0,led,0,0,0,0&quot;, &quot;0,led,1,0,0,0&quot;, &quot;0,led,2,0,0,0&quot;, &quot;0,led,3,0,0,0&quot;, &quot;0,led,4,0,0,0&quot;, &quot;0,motor,0,180,0,0&quot;], @code=[&quot;set all off; move right ear forward of degrees 180&quot;], @time=0&gt;
321
+ Request::Choregraphy.new :code =&gt; [ 'set all off', 'move right ear forward of degrees 180' ] # =&gt; #&lt;Request::Choregraphy:0x2b07a05dae30 @chor=[&quot;0,led,0,0,0,0&quot;, &quot;0,led,1,0,0,0&quot;, &quot;0,led,2,0,0,0&quot;, &quot;0,led,3,0,0,0&quot;, &quot;0,led,4,0,0,0&quot;, &quot;0,motor,0,180,0,0&quot;], @code=[&quot;set all off&quot;, &quot;move right ear forward of degrees 180&quot;], @time=0&gt;
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">&amp;</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 &gt;= 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">&gt;=</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">&quot;#{self.class}::Ears::Positions::#{cste_name}&quot;</span>
396
+ 455: <span class="ruby-ivar">@chor</span> <span class="ruby-operator">&lt;&lt;</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">&lt;&lt;</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 &gt;= 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">&gt;=</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">&quot;#{self.class}::Leds::Positions::#{cste_name}&quot;</span>
448
+ 430: <span class="ruby-ivar">@chor</span> <span class="ruby-operator">&lt;&lt;</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">&lt;&lt;</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">&lt;&lt;</span> <span class="ruby-value str">&quot;chor=10,&quot;</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">&lt;&lt;</span> <span class="ruby-node">&quot;chortitle=#{@name}&quot;</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>