module BMFF::Box::Container
vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
Attributes
children[RW]
Public Instance Methods
add_child(child)
click to toggle source
# File lib/bmff/box/container.rb, line 22 def add_child(child) @children ||= [] @children << child end
container?()
click to toggle source
# File lib/bmff/box/container.rb, line 7 def container? true end
find(boxtype)
click to toggle source
Find a box which has a specific type from my children.
# File lib/bmff/box/container.rb, line 28 def find(boxtype) (@children || []).each do |child| case boxtype when String return child if child.type == boxtype when Class return child if child.kind_of?(boxtype) end end nil end
find_all(boxtype)
click to toggle source
Find boxes which have a specific type from my children.
# File lib/bmff/box/container.rb, line 41 def find_all(boxtype) found_boxes = [] (@children || []).each do |child| case boxtype when String found_boxes << child if child.type == boxtype when Class found_boxes << child if child.kind_of?(boxtype) end end found_boxes end
parse_children()
click to toggle source
# File lib/bmff/box/container.rb, line 11 def parse_children @children = [] until eob? @children << BMFF::Box.get_box(io, self) end end
select_descendants(boxtype)
click to toggle source
Find boxes which have a specific type from my descendants.
# File lib/bmff/box/container.rb, line 55 def select_descendants(boxtype) selected_boxes = [] (@children || []).each do |child| case boxtype when String selected_boxes << child if child.type == boxtype when Class selected_boxes << child if child.kind_of?(boxtype) end if child.container? selected_boxes.concat(child.select_descendants(boxtype)) end end selected_boxes end