lib/mdl/doc.rb
##
# Find all elements of a given type, returning a list of the element
# objects themselves.
#
# Instead of a single type, a list of types can be provided instead to
# find all types.
#
# If +nested+ is set to false, this returns only top level elements of a
# given type.
Find all elements of a given type, returning a list of the element
objects themselves.

Instead of a single type, a list of types can be provided instead to
find all types.

If +nested+ is set to false, this returns only top level elements of a
given type.
Find all elements of a given type returning a list of the element objects themselves . Instead of a single type a list of types can be provided instead to find all types . If + nested + is set to false this returns only top level elements of a given type .
def find_type_elements(type, nested = true, elements = @elements)
      results = []
      type = [type] if type.instance_of?(Symbol)
      elements.each do |e|
        results.push(e) if type.include?(e.type)
        if nested && !e.children.empty?
          results.concat(find_type_elements(type, nested, e.children))
        end
      end
      results
    end
def find_type_elements ( type , nested = true , elements = @elements ) results = [ ] type = [ type ] if type . instance_of? ( Symbol ) elements . each do | e | results . push ( e ) if type . include? ( e . type ) if nested && ! e . children . empty? results . concat ( find_type_elements ( type , nested , e . children ) ) end end results end
Find all elements of a given type, returning a list of the element
objects themselves.
Find all elements of a given type returning a list of the element objects themselves .
type
<not_specific>
nested
<not_specific>
elements
<not_specific>