280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
# File 'lib/rwd/tree.rb', line 280
def parse(types=[], subtypes=[], once=false)
types = [types] if types.class == Class
subtypes = [subtypes] if subtypes.class == String
hidelevel = nil
catch :once do
@objects.each do |obj|
if (@checkvisibility and hidelevel.nil? and (not obj.visible))
hidelevel = obj.level
else
if (@checkvisibility and (not hidelevel.nil?) and obj.visible and obj.level <= hidelevel)
hidelevel = nil
end
end
if hidelevel.nil?
ok = false
catch :stop do
if types.empty?
if subtypes.empty?
ok = true
throw :stop
else
subtypes.each do |st|
if obj.subtype == st
ok = true
throw :stop
end
end
end
else
if subtypes.empty?
types.each do |t|
if obj.kind_of?(t)
ok = true
throw :stop
end
end
else
types.each do |t|
subtypes.each do |st|
if obj.kind_of?(t) and obj.subtype == st
ok = true
throw :stop
end
end
end
end
end
end
if ok
yield(obj.class.to_s, obj)
throw :once if once
end
end
end
end
end
|