Class: Gst::Bin

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gst/bin.rb

Instance Method Summary collapse

Instance Method Details

#<<(element) ⇒ Object



29
30
31
32
# File 'lib/gst/bin.rb', line 29

def <<(element)
  add_element(element)
  self
end

#add_elements(*elements) ⇒ Object Also known as: add



22
23
24
25
26
# File 'lib/gst/bin.rb', line 22

def add_elements(*elements)
  elements.each do |element|
    add_element(element)
  end
end

#each(options = {}) ⇒ Object



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