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
|
@@ -81,20 +81,37 @@
|
|
|
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="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" />
|
|
94
97
|
</map>
|
|
95
98
|
<img src="../../dot/f_8.png" usemap="#map" border="0" alt="dot/f_8.png">
|
|
96
99
|
</div>
|
|
97
100
|
|
|
101
|
+
<div id="description">
|
|
102
|
+
<p>
|
|
103
|
+
<a href="SetEarsPosition.html">SetEarsPosition</a> events change your
|
|
104
|
+
rabbit‘s ears positions. you can set left ear position, or right ear
|
|
105
|
+
position, or both.
|
|
106
|
+
</p>
|
|
107
|
+
<h1>Examples</h1>
|
|
108
|
+
<pre>
|
|
109
|
+
SetEarsPosition.new :posleft => 12 # => #<Request::SetEarsPosition:0x2ad0b2c79680 @h={:posleft=>12}>
|
|
110
|
+
SetEarsPosition.new :posright => 1 # => #<Request::SetEarsPosition:0x2ad0b2c70260 @h={:posright=>1}>
|
|
111
|
+
SetEarsPosition.new :posright => 5, :posleft => 5 # => #<Request::SetEarsPosition:0x2ad0b2c5e330 @h={:posleft=>5, :posright=>5}>
|
|
112
|
+
</pre>
|
|
113
|
+
|
|
114
|
+
</div>
|
|
98
115
|
|
|
99
116
|
|
|
100
117
|
</div>
|
|
@@ -103,8 +120,8 @@
|
|
|
103
120
|
<h3 class="section-bar">Methods</h3>
|
|
104
121
|
|
|
105
122
|
<div class="name-list">
|
|
106
|
-
<a href="#
|
|
107
|
-
<a href="#
|
|
123
|
+
<a href="#M000042">new</a>
|
|
124
|
+
<a href="#M000043">to_url</a>
|
|
108
125
|
</div>
|
|
109
126
|
</div>
|
|
110
127
|
|
|
@@ -144,27 +161,32 @@
|
|
|
144
161
|
<div id="methods">
|
|
145
162
|
<h3 class="section-bar">Public Class methods</h3>
|
|
146
163
|
|
|
147
|
-
<div id="method-
|
|
148
|
-
<a name="
|
|
164
|
+
<div id="method-M000042" class="method-detail">
|
|
165
|
+
<a name="M000042"></a>
|
|
149
166
|
|
|
150
167
|
<div class="method-heading">
|
|
151
|
-
<a href="#
|
|
168
|
+
<a href="#M000042" class="method-signature">
|
|
152
169
|
<span class="method-name">new</span><span class="method-args">(h)</span>
|
|
153
170
|
</a>
|
|
154
171
|
</div>
|
|
155
172
|
|
|
156
173
|
<div class="method-description">
|
|
174
|
+
<p>
|
|
175
|
+
take an hash in parameter, with <tt>:posright</tt> and/or <tt>:posleft</tt>
|
|
176
|
+
keys. values should be between SetEarsPosition::MIN_POS and
|
|
177
|
+
SetEarsPosition::MAX_POS.
|
|
178
|
+
</p>
|
|
157
179
|
<p><a class="source-toggle" href="#"
|
|
158
|
-
onclick="toggleCode('
|
|
159
|
-
<div class="method-source-code" id="
|
|
180
|
+
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
|
181
|
+
<div class="method-source-code" id="M000042-source">
|
|
160
182
|
<pre>
|
|
161
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
183
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 152</span>
|
|
184
|
+
152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">h</span>
|
|
185
|
+
153: <span class="ruby-ivar">@h</span> = <span class="ruby-identifier">h</span>.<span class="ruby-identifier">dup</span>
|
|
186
|
+
154: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'at least :posright or :posleft must be set'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posleft</span>] <span class="ruby-keyword kw">or</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posright</span>]
|
|
187
|
+
155: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">":posright must be between #{MIN_POS} and #{MAX_POS}"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posright</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posright</span>].<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-constant">MIN_POS</span>,<span class="ruby-constant">MAX_POS</span>)
|
|
188
|
+
156: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">":posleft must be between #{MIN_POS} and #{MAX_POS}"</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posleft</span> ] <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posleft</span> ].<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-constant">MIN_POS</span>,<span class="ruby-constant">MAX_POS</span>)
|
|
189
|
+
157: <span class="ruby-keyword kw">end</span>
|
|
168
190
|
</pre>
|
|
169
191
|
</div>
|
|
170
192
|
</div>
|
|
@@ -172,27 +194,27 @@
|
|
|
172
194
|
|
|
173
195
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
174
196
|
|
|
175
|
-
<div id="method-
|
|
176
|
-
<a name="
|
|
197
|
+
<div id="method-M000043" class="method-detail">
|
|
198
|
+
<a name="M000043"></a>
|
|
177
199
|
|
|
178
200
|
<div class="method-heading">
|
|
179
|
-
<a href="#
|
|
201
|
+
<a href="#M000043" class="method-signature">
|
|
180
202
|
<span class="method-name">to_url</span><span class="method-args">()</span>
|
|
181
203
|
</a>
|
|
182
204
|
</div>
|
|
183
205
|
|
|
184
206
|
<div class="method-description">
|
|
185
207
|
<p><a class="source-toggle" href="#"
|
|
186
|
-
onclick="toggleCode('
|
|
187
|
-
<div class="method-source-code" id="
|
|
208
|
+
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
|
209
|
+
<div class="method-source-code" id="M000043-source">
|
|
188
210
|
<pre>
|
|
189
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
211
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 159</span>
|
|
212
|
+
159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_url</span>
|
|
213
|
+
160: <span class="ruby-identifier">url</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
|
214
|
+
161: <span class="ruby-identifier">url</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"posleft=#{@h[:posleft].to_i}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posleft</span>]
|
|
215
|
+
162: <span class="ruby-identifier">url</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"posright=#{@h[:posright].to_i}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:posright</span>]
|
|
216
|
+
163: <span class="ruby-identifier">url</span>.<span class="ruby-identifier">sort</span>
|
|
217
|
+
164: <span class="ruby-keyword kw">end</span>
|
|
196
218
|
</pre>
|
|
197
219
|
</div>
|
|
198
220
|
</div>
|
|
@@ -81,20 +81,36 @@
|
|
|
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="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" />
|
|
94
97
|
</map>
|
|
95
98
|
<img src="../../dot/f_8.png" usemap="#map" border="0" alt="dot/f_8.png">
|
|
96
99
|
</div>
|
|
97
100
|
|
|
101
|
+
<div id="description">
|
|
102
|
+
<p>
|
|
103
|
+
<a href="TtsMessage.html">TtsMessage</a> events are used to Text-To-Speach
|
|
104
|
+
messages.
|
|
105
|
+
</p>
|
|
106
|
+
<h1>Examples</h1>
|
|
107
|
+
<pre>
|
|
108
|
+
TtsMessage.new :tts => "oups!" # => #<Request::TtsMessage:0x2ab1ba3cd8e0 @h={:tts=>"oups!"}>
|
|
109
|
+
TtsMessage.new :tts => "allez hop !", :speed => 200, :voice => "caroline22k" # => #<Request::TtsMessage:0x2ab1ba3b8e40 @h={:tts=>"allez%20hop%20!", :speed=>200, :voice=>"caroline22k"}>
|
|
110
|
+
TtsMessage.new :tts => "GNU is Not Unix", :speed => 200, :pitch => 400 # => #<Request::TtsMessage:0x2ab1ba3a9580 @h={:tts=>"GNU%20is%20Not%20Unix", :speed=>200, :pitch=>400}>
|
|
111
|
+
</pre>
|
|
112
|
+
|
|
113
|
+
</div>
|
|
98
114
|
|
|
99
115
|
|
|
100
116
|
</div>
|
|
@@ -103,8 +119,8 @@
|
|
|
103
119
|
<h3 class="section-bar">Methods</h3>
|
|
104
120
|
|
|
105
121
|
<div class="name-list">
|
|
106
|
-
<a href="#
|
|
107
|
-
<a href="#
|
|
122
|
+
<a href="#M000038">new</a>
|
|
123
|
+
<a href="#M000039">to_url</a>
|
|
108
124
|
</div>
|
|
109
125
|
</div>
|
|
110
126
|
|
|
@@ -129,7 +145,7 @@
|
|
|
129
145
|
<tr class="top-aligned-row context-row">
|
|
130
146
|
<td class="context-item-name">MAX_SPEED</td>
|
|
131
147
|
<td>=</td>
|
|
132
|
-
<td class="context-item-value">
|
|
148
|
+
<td class="context-item-value">32_000</td>
|
|
133
149
|
</tr>
|
|
134
150
|
<tr class="top-aligned-row context-row">
|
|
135
151
|
<td class="context-item-name">MIN_PITCH</td>
|
|
@@ -139,7 +155,7 @@
|
|
|
139
155
|
<tr class="top-aligned-row context-row">
|
|
140
156
|
<td class="context-item-name">MAX_PITCH</td>
|
|
141
157
|
<td>=</td>
|
|
142
|
-
<td class="context-item-value">
|
|
158
|
+
<td class="context-item-value">32_000</td>
|
|
143
159
|
</tr>
|
|
144
160
|
</table>
|
|
145
161
|
</div>
|
|
@@ -154,38 +170,47 @@
|
|
|
154
170
|
<div id="methods">
|
|
155
171
|
<h3 class="section-bar">Public Class methods</h3>
|
|
156
172
|
|
|
157
|
-
<div id="method-
|
|
158
|
-
<a name="
|
|
173
|
+
<div id="method-M000038" class="method-detail">
|
|
174
|
+
<a name="M000038"></a>
|
|
159
175
|
|
|
160
176
|
<div class="method-heading">
|
|
161
|
-
<a href="#
|
|
177
|
+
<a href="#M000038" class="method-signature">
|
|
162
178
|
<span class="method-name">new</span><span class="method-args">(h)</span>
|
|
163
179
|
</a>
|
|
164
180
|
</div>
|
|
165
181
|
|
|
166
182
|
<div class="method-description">
|
|
183
|
+
<p>
|
|
184
|
+
take an hash in parameter, with at least <tt>:tts</tt> key. the
|
|
185
|
+
<tt>:tts</tt> key must be a string encoded in UTF-8. Optionals parameters
|
|
186
|
+
are <tt>:speed</tt> and <tt>:pitch</tt>, they must be between MIN_SPEED and
|
|
187
|
+
MAX_SPEED (MIN_PITCH and MAX_PITCH respectively). Default values for
|
|
188
|
+
speed/pitch is 100.
|
|
189
|
+
</p>
|
|
167
190
|
<p><a class="source-toggle" href="#"
|
|
168
|
-
onclick="toggleCode('
|
|
169
|
-
<div class="method-source-code" id="
|
|
191
|
+
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
|
192
|
+
<div class="method-source-code" id="M000038-source">
|
|
170
193
|
<pre>
|
|
171
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
194
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 184</span>
|
|
195
|
+
184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">h</span>
|
|
196
|
+
185: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'no :tts given'</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:tts</span>]
|
|
197
|
+
186: <span class="ruby-ivar">@h</span> = <span class="ruby-identifier">h</span>.<span class="ruby-identifier">dup</span>
|
|
198
|
+
187:
|
|
199
|
+
188: [<span class="ruby-identifier">:speed</span>,<span class="ruby-identifier">:pitch</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
|
200
|
+
189: <span class="ruby-identifier">min</span> = <span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">constantize</span>(<span class="ruby-node">"#{self.class}::MIN_#{k.to_s.upcase}"</span>)
|
|
201
|
+
190: <span class="ruby-identifier">max</span> = <span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">constantize</span>(<span class="ruby-node">"#{self.class}::MAX_#{k.to_s.upcase}"</span>)
|
|
202
|
+
191:
|
|
203
|
+
192: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">between?</span>(<span class="ruby-identifier">min</span>,<span class="ruby-identifier">max</span>)
|
|
204
|
+
193: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{k} values must be between #{min} and #{max}"</span>)
|
|
205
|
+
194: <span class="ruby-keyword kw">else</span>
|
|
206
|
+
195: <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">to_i</span>
|
|
207
|
+
196: <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">k</span>]
|
|
208
|
+
197: <span class="ruby-keyword kw">end</span>
|
|
209
|
+
198:
|
|
210
|
+
199: <span class="ruby-comment cmt"># to have a well formatted url</span>
|
|
211
|
+
200: <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:tts</span>] = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">escape</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:tts</span>]
|
|
212
|
+
201: <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:nabcasttitle</span>] = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">escape</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:nabcasttitle</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@h</span>[<span class="ruby-identifier">:nabcasttitle</span>]
|
|
213
|
+
202: <span class="ruby-keyword kw">end</span>
|
|
189
214
|
</pre>
|
|
190
215
|
</div>
|
|
191
216
|
</div>
|
|
@@ -193,28 +218,27 @@
|
|
|
193
218
|
|
|
194
219
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
195
220
|
|
|
196
|
-
<div id="method-
|
|
197
|
-
<a name="
|
|
221
|
+
<div id="method-M000039" class="method-detail">
|
|
222
|
+
<a name="M000039"></a>
|
|
198
223
|
|
|
199
224
|
<div class="method-heading">
|
|
200
|
-
<a href="#
|
|
225
|
+
<a href="#M000039" class="method-signature">
|
|
201
226
|
<span class="method-name">to_url</span><span class="method-args">()</span>
|
|
202
227
|
</a>
|
|
203
228
|
</div>
|
|
204
229
|
|
|
205
230
|
<div class="method-description">
|
|
206
231
|
<p><a class="source-toggle" href="#"
|
|
207
|
-
onclick="toggleCode('
|
|
208
|
-
<div class="method-source-code" id="
|
|
232
|
+
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
|
233
|
+
<div class="method-source-code" id="M000039-source">
|
|
209
234
|
<pre>
|
|
210
|
-
<span class="ruby-comment cmt"># File lib/violet/request.rb, line
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
164: <span class="ruby-keyword kw">end</span>
|
|
235
|
+
<span class="ruby-comment cmt"># File lib/violet/request.rb, line 204</span>
|
|
236
|
+
204: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_url</span>
|
|
237
|
+
205: <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@h</span>
|
|
238
|
+
206: (<span class="ruby-identifier">url</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>) <span class="ruby-operator"><<</span> <span class="ruby-node">"#{key}=#{val}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>
|
|
239
|
+
207: <span class="ruby-keyword kw">end</span>
|
|
240
|
+
208: <span class="ruby-identifier">url</span>.<span class="ruby-identifier">sort</span>
|
|
241
|
+
209: <span class="ruby-keyword kw">end</span>
|
|
218
242
|
</pre>
|
|
219
243
|
</div>
|
|
220
244
|
</div>
|
data/doc/classes/Response.html
CHANGED
|
@@ -73,116 +73,47 @@
|
|
|
73
73
|
<div id="contextContent">
|
|
74
74
|
<div id="diagram">
|
|
75
75
|
<map id="map" name="map">
|
|
76
|
-
<area shape="rect" coords="
|
|
76
|
+
<area shape="rect" coords="1621,229,1731,277" href="Response/Base/GoodServerRsp.html" alt="GoodServerRsp" />
|
|
77
77
|
<area shape="rect" coords="27,325,136,373" href="Response/EarPositionSend.html" alt="EarPositionSend" />
|
|
78
78
|
<area shape="rect" coords="160,325,256,373" href="Response/NabCastSend.html" alt="NabCastSend" />
|
|
79
|
-
<area shape="rect" coords="280,325,
|
|
80
|
-
<area shape="rect" coords="
|
|
81
|
-
<area shape="rect" coords="
|
|
82
|
-
<area shape="rect" coords="
|
|
83
|
-
<area shape="rect" coords="
|
|
79
|
+
<area shape="rect" coords="280,325,381,373" href="Response/CommandSend.html" alt="CommandSend" />
|
|
80
|
+
<area shape="rect" coords="405,325,483,373" href="Response/Signature.html" alt="Signature" />
|
|
81
|
+
<area shape="rect" coords="507,325,589,373" href="Response/PositionEar.html" alt="PositionEar" />
|
|
82
|
+
<area shape="rect" coords="613,325,704,373" href="Response/VoiceListTts.html" alt="VoiceListTts" />
|
|
83
|
+
<area shape="rect" coords="728,325,819,373" href="Response/LinkPreview.html" alt="LinkPreview" />
|
|
84
84
|
<area shape="rect" coords="843,325,941,373" href="Response/MessageSend.html" alt="MessageSend" />
|
|
85
85
|
<area shape="rect" coords="965,325,1059,373" href="Response/LangListUser.html" alt="LangListUser" />
|
|
86
|
-
<area shape="rect" coords="1083,325,
|
|
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="
|
|
94
|
-
<area shape="rect" coords="
|
|
95
|
-
<area shape="rect" coords="
|
|
96
|
-
<area shape="rect" coords="
|
|
97
|
-
<area shape="rect" coords="
|
|
98
|
-
<area shape="rect" coords="
|
|
99
|
-
<area shape="rect" coords="
|
|
100
|
-
<area shape="rect" coords="
|
|
101
|
-
<area shape="rect" coords="
|
|
102
|
-
<area shape="rect" coords="
|
|
103
|
-
<area shape="rect" coords="
|
|
104
|
-
<area shape="rect" coords="
|
|
105
|
-
<area shape="rect" coords="
|
|
106
|
-
<area shape="rect" coords="
|
|
107
|
-
<area shape="rect" coords="
|
|
108
|
-
<area shape="rect" coords="
|
|
109
|
-
<area shape="rect" coords="
|
|
110
|
-
<area shape="rect" coords="
|
|
111
|
-
<area shape="rect" coords="
|
|
112
|
-
<area shape="rect" coords="16,64,
|
|
86
|
+
<area shape="rect" coords="1083,325,1171,373" href="Response/RabbitName.html" alt="RabbitName" />
|
|
87
|
+
<area shape="rect" coords="1195,325,1267,373" href="Response/TtsSend.html" alt="TtsSend" />
|
|
88
|
+
<area shape="rect" coords="1291,325,1403,373" href="Response/ListReceivedMsg.html" alt="ListReceivedMsg" />
|
|
89
|
+
<area shape="rect" coords="1427,325,1504,373" href="Response/ListFriend.html" alt="ListFriend" />
|
|
90
|
+
<area shape="rect" coords="1528,325,1616,373" href="Response/RabbitSleep.html" alt="RabbitSleep" />
|
|
91
|
+
<area shape="rect" coords="1640,325,1712,373" href="Response/Blacklist.html" alt="Blacklist" />
|
|
92
|
+
<area shape="rect" coords="1736,325,1813,373" href="Response/Timezone.html" alt="Timezone" />
|
|
93
|
+
<area shape="rect" coords="1837,325,1936,373" href="Response/RabbitVersion.html" alt="RabbitVersion" />
|
|
94
|
+
<area shape="rect" coords="1960,325,2064,373" href="Response/WebRadioSend.html" alt="WebRadioSend" />
|
|
95
|
+
<area shape="rect" coords="2088,325,2165,373" href="Response/ChorSend.html" alt="ChorSend" />
|
|
96
|
+
<area shape="rect" coords="1755,229,1856,277" href="Response/Base/BadServerRsp.html" alt="BadServerRsp" />
|
|
97
|
+
<area shape="rect" coords="2189,325,2325,373" href="Response/NoGoodTokenOrSerial.html" alt="NoGoodTokenOrSerial" />
|
|
98
|
+
<area shape="rect" coords="2349,325,2443,373" href="Response/ChorNotSend.html" alt="ChorNotSend" />
|
|
99
|
+
<area shape="rect" coords="2467,325,2579,373" href="Response/NabCastNotSend.html" alt="NabCastNotSend" />
|
|
100
|
+
<area shape="rect" coords="2603,325,2717,373" href="Response/MessageNotSend.html" alt="MessageNotSend" />
|
|
101
|
+
<area shape="rect" coords="2741,325,2843,373" href="Response/AbuseSending.html" alt="AbuseSending" />
|
|
102
|
+
<area shape="rect" coords="2867,325,3000,373" href="Response/NoCorrectParameters.html" alt="NoCorrectParameters" />
|
|
103
|
+
<area shape="rect" coords="3024,325,3109,373" href="Response/TtsNotSend.html" alt="TtsNotSend" />
|
|
104
|
+
<area shape="rect" coords="3133,325,3224,373" href="Response/NotV2Rabbit.html" alt="NotV2Rabbit" />
|
|
105
|
+
<area shape="rect" coords="3248,325,3368,373" href="Response/WebRadioNotSend.html" alt="WebRadioNotSend" />
|
|
106
|
+
<area shape="rect" coords="3392,325,3517,373" href="Response/EarPositionNotSend.html" alt="EarPositionNotSend" />
|
|
107
|
+
<area shape="rect" coords="1136,5,1235,53" href="StandardError.html" alt="StandardError" />
|
|
108
|
+
<area shape="rect" coords="1128,133,1243,181" href="Response/ProtocolExcepion.html" alt="ProtocolExcepion" />
|
|
109
|
+
<area shape="rect" coords="1764,133,1847,181" href="Response/Base/ServerRsp.html" alt="ServerRsp" />
|
|
110
|
+
<area shape="rect" coords="1880,229,1992,277" href="Response/EmptyServerRsp.html" alt="EmptyServerRsp" />
|
|
111
|
+
<area shape="rect" coords="1611,99,1867,288" href="Response/Base.html" alt="Base" />
|
|
112
|
+
<area shape="rect" coords="16,64,3528,384" href="Response.html" alt="Response" />
|
|
113
113
|
</map>
|
|
114
|
-
<img src="../dot/
|
|
114
|
+
<img src="../dot/f_6.png" usemap="#map" border="0" alt="dot/f_6.png">
|
|
115
115
|
</div>
|
|
116
116
|
|
|
117
|
-
<div id="description">
|
|
118
|
-
<h1>violet/response.rb</h1>
|
|
119
|
-
<h2>Summary</h2>
|
|
120
|
-
<p>
|
|
121
|
-
this module handle servers messages. Main method/class are <a
|
|
122
|
-
href="Response.html#M000003">Response.parse</a> and <a
|
|
123
|
-
href="Response/Base/ServerRsp.html">Response::Base::ServerRsp</a> (well
|
|
124
|
-
documented).
|
|
125
|
-
</p>
|
|
126
|
-
<p>
|
|
127
|
-
you should only use <a href="Response.html#M000003">Response.parse</a> with
|
|
128
|
-
the server‘s message (xml) as argument, it returns a ServerRsp
|
|
129
|
-
instance from the corresponding class (see all the ServerRsp subclass).
|
|
130
|
-
with a ServerRsp instance you can use :
|
|
131
|
-
</p>
|
|
132
|
-
<dl>
|
|
133
|
-
<dt> r.has_x? </dt><dd>return <tt>true</tt> if r has at least one element of name "x",
|
|
134
|
-
return <tt>false</tt> otherwhise.
|
|
135
|
-
|
|
136
|
-
</dd>
|
|
137
|
-
<dt> r.has_many_xs? </dt><dd>return <tt>true</tt> if r has more than one element of name "x",
|
|
138
|
-
return <tt>false</tt> otherwhise.
|
|
139
|
-
|
|
140
|
-
</dd>
|
|
141
|
-
<dt> r.x </dt><dd>find the first xml element of name x and return it‘s text if any, or
|
|
142
|
-
a hash of it‘s options
|
|
143
|
-
|
|
144
|
-
</dd>
|
|
145
|
-
<dt> r.x </dt><dd>find all xml element of name x and return an Array of their text if any, or
|
|
146
|
-
their options.
|
|
147
|
-
|
|
148
|
-
</dd>
|
|
149
|
-
<dt> r.good? </dt><dd>return <tt>true</tt> if the response is not an error, <tt>false</tt>
|
|
150
|
-
otherwhise.
|
|
151
|
-
|
|
152
|
-
</dd>
|
|
153
|
-
<dt> r.bad? </dt><dd>return <tt>true</tt> if the response is an error, <tt>false</tt>
|
|
154
|
-
otherwhise.
|
|
155
|
-
|
|
156
|
-
</dd>
|
|
157
|
-
</dl>
|
|
158
|
-
<h2>Examples :</h2>
|
|
159
|
-
<pre>
|
|
160
|
-
>> rsp = Response.parse('<?xml version="1.0" encoding="UTF-8"?><rsp><blacklist nb="2"/><pseudo name="toto"/><pseudo name="titi"/></rsp>')
|
|
161
|
-
=> #<Response::Blacklist:0x2acd8c08f2f8 @xml=<UNDEFINED> ... </>>
|
|
162
|
-
>> rsp.good?
|
|
163
|
-
=> true
|
|
164
|
-
>> rsp.has_message?
|
|
165
|
-
=> false
|
|
166
|
-
>> rsp.message
|
|
167
|
-
NameError: undefined local variable or method message for #<Response::Blacklist:0x2b1f056afdc0 @xml=<UNDEFINED> ... </>>
|
|
168
|
-
>> rsp.has_blacklist?
|
|
169
|
-
=> true
|
|
170
|
-
>> rsp.blacklist
|
|
171
|
-
=> {:nb=>"2"}
|
|
172
|
-
>> rsp.pseudo
|
|
173
|
-
=> {:name=>"toto"}
|
|
174
|
-
>> rsp.has_many_pseudos?
|
|
175
|
-
=> true
|
|
176
|
-
>> rsp.pseudos
|
|
177
|
-
=> [{:name=>"toto"}, {:name=>"titi"}]
|
|
178
|
-
</pre>
|
|
179
|
-
<h2>Low Level</h2>
|
|
180
|
-
<p>
|
|
181
|
-
if you want to access to the REXML::Document object of a ServerRsp you can
|
|
182
|
-
either use rsp.xml or use ServerRsp#get_all method.
|
|
183
|
-
</p>
|
|
184
|
-
|
|
185
|
-
</div>
|
|
186
117
|
|
|
187
118
|
|
|
188
119
|
</div>
|
|
@@ -296,27 +227,27 @@ fail to detect the kind of the server‘s response.
|
|
|
296
227
|
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
|
297
228
|
<div class="method-source-code" id="M000003-source">
|
|
298
229
|
<pre>
|
|
299
|
-
<span class="ruby-comment cmt"># File lib/violet/response.rb, line
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
230
|
+
<span class="ruby-comment cmt"># File lib/violet/response.rb, line 393</span>
|
|
231
|
+
393: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Response</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">raw</span>
|
|
232
|
+
394: <span class="ruby-identifier">tmp</span> = <span class="ruby-constant">Base</span><span class="ruby-operator">::</span><span class="ruby-constant">ServerRsp</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">raw</span> <span class="ruby-comment cmt"># we shouldn't create ServerRsp instances, but act as if you didn't see ;)</span>
|
|
233
|
+
395: <span class="ruby-identifier">klassname</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">raw</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">%r|<rsp>\s*</rsp>|i</span>
|
|
234
|
+
396: <span class="ruby-value str">'EmptyServerRsp'</span>
|
|
235
|
+
397: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">has_message?</span>
|
|
236
|
+
398: <span class="ruby-node">/^#{tmp.message}$/i</span>
|
|
237
|
+
399: <span class="ruby-keyword kw">else</span>
|
|
238
|
+
400: <span class="ruby-node">/^#{tmp.xml.root.elements[1].name}$/i</span> <span class="ruby-comment cmt"># REXML::Elements#[] has index 1-based and not 0-based, so we really fetch the first element's name</span>
|
|
239
|
+
401: <span class="ruby-keyword kw">end</span>
|
|
240
|
+
402:
|
|
241
|
+
403: <span class="ruby-identifier">klass</span> = <span class="ruby-keyword kw">nil</span>
|
|
242
|
+
404: <span class="ruby-keyword kw">begin</span>
|
|
243
|
+
405: <span class="ruby-identifier">klass</span> = <span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">constantize</span> <span class="ruby-node">"#{self}::#{Response.constants.grep(klassname).first}"</span>
|
|
244
|
+
406: <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">nil?</span>
|
|
245
|
+
407: <span class="ruby-keyword kw">rescue</span>
|
|
246
|
+
408: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ProtocolExcepion</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"unknown server's response : #{raw}"</span>)
|
|
247
|
+
409: <span class="ruby-keyword kw">end</span>
|
|
248
|
+
410:
|
|
249
|
+
411: <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">raw</span>
|
|
250
|
+
412: <span class="ruby-keyword kw">end</span>
|
|
320
251
|
</pre>
|
|
321
252
|
</div>
|
|
322
253
|
</div>
|