34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/gst/bin.rb', line 34
def each(options={})
return to_enum(:each, options) unless block_given?
if options[:recurse]
iterator = iterate_recurse
elsif options[:sink]
iterator = iterate_sinks
elsif options[:sorted]
iterator = iterate_sorted
elsif options[:sources]
iterator = iterate_sources
elsif options[:interface]
iterator = iterate_all_by_interface(options[:interface])
else
iterator = iterate_elements
end
loop do
result, element = iterator.next
case result
when IteratorResult::DONE
break
when IteratorResult::OK
yield(element.value)
when IteratorResult::RESYNC
iterator.resync
when IteratorResult::ERROR
raise "failed to iterate"
end
end
end
|