perception 0.3.4 → 0.3.5

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/demo/demo_zz.rb DELETED
@@ -1,333 +0,0 @@
1
- # ruby encoding: utf-8
2
- # ü
3
- if $0 == __FILE__
4
- require 'drumherum'
5
- smart_init
6
- require 'perception'
7
- end
8
-
9
-
10
- module Perception #:nodoc
11
-
12
- class DemoSee
13
- @@initialized_count = 0
14
-
15
- def initialize( announce_first=true )
16
- @@initialized_count += 1
17
- return if (@@initialized_count == 1 && !announce_first)
18
- seee.fast!
19
- #seee.left!
20
- seee.indent!
21
- see ("\n" * 5) if @@initialized_count > 1
22
- see "Perception Demo ##{@@initialized_count}"
23
- see "=================="
24
- see
25
- wait_for_key('Press any key to start')
26
- end # def
27
-
28
-
29
-
30
- # Printing basic types
31
- def demo_see_basic_types
32
- see '1dim Arrays:'
33
- see a=['this','is','an','array','1']
34
- see b=['this','is','another','array','2']
35
- see c=['and','this','is','another', :tree]
36
- see d=['complex array', [1,2,3], {:key => :value, :love => :baby}, 4.0, :four]
37
- see d=['next','is','two','blank', 'lines']
38
- see
39
- see
40
- see '2dim Arrays'
41
- see [a,b,c,d]
42
- see
43
- see
44
- see 'Other Objects:'
45
- see []
46
- see 'ordinary string (without "")'
47
- see '(next one is empty)'
48
- see ''
49
- see 1
50
- see 2
51
- see 3.0
52
- see nil
53
- see true
54
- see false
55
- see :a_symbol
56
- see({:key => :value, :love => :baby})
57
- see ['complex array', [1,2,3], {:key => :value, :love => :baby}, 3.0 , '']
58
- end # def
59
-
60
-
61
- def demo_level
62
- seee.slow!
63
- see "The printout is automaticaly indented. This is the printout of a nested structure of #see's:"
64
- see
65
- see
66
- seee.indent!
67
- sub_demo_level
68
- see
69
- see
70
- wait_for_key
71
- see 'You can force left printout with seee.left!. Reactivate indention with seee.indent!.'
72
- seee.left!
73
- see
74
- see
75
- sub_demo_level
76
- end
77
-
78
-
79
- def sub_demo_level
80
- see "Hello world. This is level zero. "
81
- (1..1).each do
82
- see "This is the beginning of level one."
83
- 1.downto(1) do
84
- see "This is the beginning of level two."
85
- 1.upto(1) do
86
- see "This is the beginning of level three."
87
- 1.times do
88
- see "This is the beginning of level four."
89
- see "This is the end of level four."
90
- end
91
- see "This is the end of level three."
92
- end
93
- see "This is the end of level two."
94
- end
95
- see "This is the end of level one."
96
- end
97
- see "This is level zero again. Bye. "
98
- end # def
99
-
100
-
101
-
102
-
103
-
104
-
105
- # slow printing
106
- def demo_see_slowdown1
107
- seee.slow!
108
- see 'This is a string'
109
- see 'and here we have a longer one.'
110
- see 'so we need even longeer strings, but they all have to be different.'
111
- see '#see has forgotten the first string. So I will tell him again: This is a string. and here we have a longer one. '
112
- see 'In slow mode #see waits for you to read the lines. More words, longer waiting.'
113
- see 'short prints...'
114
- see '...short waiting.'
115
- see 'short prints...'
116
- see '...short waiting.'
117
- string = 'This string is getting longer.'
118
- (1..10).each do |i|
119
- see string
120
- string += ' But it repeats.'
121
- end
122
- see '#see only counts those words you have to read.'
123
- see 'You can choose the speed. This is faster:'
124
-
125
- wait_for_key
126
- see
127
- seee.slow!(0.5)
128
- see 'This is a string'
129
- see 'and here we have a longer one.'
130
- see 'so we need even longeer strings, but they all have to be different.'
131
- see '#see has forgotten the first string. So I will tell him again: This is a string. and here we have a longer one. '
132
- see 'In slow mode #see waits for you to read the lines. More words, longer waiting.'
133
- see 'short prints...'
134
- see '...short waiting.'
135
- see '...short waiting.'
136
- string = 'This string is getting longer.'
137
- (1..10).each do |i|
138
- see string
139
- string += ' But it repeats.'
140
- end
141
- see '#see only counts those words you have to read.'
142
- see
143
- end
144
-
145
-
146
- def demo_see_slowdown2
147
- seee.slow!
148
- (1..8).each do |i|
149
- see "#{i} see this "
150
- end
151
- (1..8).each do |i|
152
- see "#{i} see that "
153
- sleep 0.05
154
- end
155
- see 'The speed was always the same, but each "see that" took double the time.'
156
- see '#see knows the time since last print.'
157
- see 'You can use this for simple benchmarking:'
158
- end
159
-
160
-
161
- # Simple benchmarking
162
- def demo_bench
163
- see "I'm counting to 10 000 000, please wait."
164
- 10000000.downto(0) {}
165
- see "it took #{seee.bench} seconds."
166
- see 'You always get the time since last print with seee.bench.'
167
- end
168
-
169
-
170
- # temporary printing
171
- def demo_see_temp_and_clear_last
172
- seee.slow!
173
- see_print "countdown: "
174
- 10.downto(0) do |i|
175
- see_temp i
176
- end
177
- see 'finished!'
178
- sleep 1
179
- seee.clear!
180
- see 'You can clear the last print with seee.clear!'
181
- see 'And you can print temporary informations with see_temp'
182
- end
183
-
184
-
185
- # print two informations on one line
186
- def demo_see_flash1
187
- seee.fast!
188
- (1..1000).each do |i|
189
- see "I am line number #{i}. Waiting for line number 327."
190
- seee.flash! if i == 327
191
- end
192
- see 'You can make the last printout blink with seee.flash!'
193
- end
194
-
195
-
196
- # print two informations on one line
197
- def demo_alternate_see
198
- see ['this','is','an','array',:one]
199
- see ['this','is','an','array',:two]
200
- see ['this','is','an','array',:three]
201
- see ['this', [1,2,3], {:wEDSG => :DZHe5D, :DShg => :DGStdf}, 4.0, :four]
202
- seee.flash! ' Hoops!! '
203
- see ['this','is','an','array',:five]
204
- see ['this','is','an','array',:six]
205
- see ['this','is','an','array',:seven]
206
- end
207
-
208
-
209
- def demo_flash_puts
210
- see 'Bla Bla '
211
- see 'Bla Bla '
212
- see 'Bla Bla '
213
- see 'Bla Bla '
214
- see 'Bla Bla '
215
- see 'Bla Bla '
216
- see 'Bla Bla '
217
- see 'Bla Bla '
218
- see 'Important'
219
- seee.flash!
220
- see 'Bla Bla '
221
- see 'Bla Bla '
222
- see 'Bla Bla '
223
- see 'Bla Bla '
224
- see 'Bla Bla '
225
- see 'Bla Bla '
226
- see 'Bla Bla '
227
- see 'Bla Bla '
228
- end
229
-
230
-
231
- def demo_flash_pp
232
- see_pp 'Bla Bla '
233
- see_pp 'Bla Bla '
234
- see_pp 'Bla Bla '
235
- see_pp 'Bla Bla '
236
- see_pp 'Bla Bla '
237
- see_pp 'Bla Bla '
238
- see_pp 'Bla Bla '
239
- see_pp 'Bla Bla '
240
- see_pp 'Important '
241
- seee.flash!
242
- see_pp 'Bla Bla '
243
- see_pp 'Bla Bla '
244
- see_pp 'Bla Bla '
245
- see_pp 'Bla Bla '
246
- see_pp 'Bla Bla '
247
- see_pp 'Bla Bla '
248
- see_pp 'Bla Bla '
249
- see_pp 'Bla Bla '
250
- end
251
-
252
-
253
- def demo_flash_print
254
- see_print 'Bla Bla '
255
- see_print 'Bla Bla '
256
- see_print 'Bla Bla '
257
- see_print 'Bla Bla '
258
- see_print 'Bla Bla '
259
- see_print 'Bla Bla '
260
- see_print 'Bla Bla '
261
- see_print 'Bla Bla '
262
- see_print 'Important '
263
- seee.flash!
264
- see_print 'Bla Bla '
265
- see_print 'Bla Bla '
266
- see_print 'Bla Bla '
267
- see_print 'Bla Bla '
268
- see_print 'Bla Bla '
269
- see_print 'Bla Bla '
270
- see_print 'Bla Bla '
271
- see_print 'Bla Bla '
272
- end
273
-
274
-
275
- def demo_noinput
276
- method = :see
277
- seee.slow!
278
- Object.send(method, 'Hallo')
279
- Object.send(method)
280
- Object.send(method, 'Welt')
281
- Object.send(method)
282
- Object.send(method, 'Double')
283
- Object.send(method)
284
- Object.send(method)
285
- Object.send(method, 'Space')
286
- Object.send(method)
287
- Object.send(method)
288
- Object.send(method, 'Blubb')
289
- Object.send(method)
290
- Object.send(method)
291
- Object.send(method, 'Blubb!!')
292
- end
293
-
294
-
295
-
296
-
297
- def self.see_all_demos
298
- Perception::DemoSee.new.demo_see_basic_types
299
- Perception::DemoSee.new.demo_level
300
- Perception::DemoSee.new.demo_see_slowdown1
301
- Perception::DemoSee.new.demo_see_slowdown2
302
- Perception::DemoSee.new.demo_bench
303
- Perception::DemoSee.new.demo_see_temp_and_clear_last
304
- Perception::DemoSee.new.demo_see_flash1
305
- Perception::DemoSee.new.demo_alternate_see
306
-
307
- Perception::DemoSee.new.demo_flash_puts
308
- Perception::DemoSee.new.demo_flash_pp
309
- Perception::DemoSee.new.demo_flash_print
310
- Perception::DemoSee.new.demo_noinput
311
- end
312
-
313
-
314
-
315
- end # class
316
- end # class
317
-
318
-
319
- if $0 == __FILE__ then
320
-
321
- Perception::DemoSee.see_all_demos
322
-
323
- end
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-