lib/mdl/doc.rb
##
# A variation on find_type_elements that allows you to skip drilling down
# into children of specific element types.
#
# Instead of a single type, a list of types can be provided instead to
# find all types.
#
# Unlike find_type_elements, this method will always search for nested
# elements, and skip the element types given to nested_except.
A variation on find_type_elements that allows you to skip drilling down
into children of specific element types.

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

Unlike find_type_elements, this method will always search for nested
elements, and skip the element types given to nested_except.
A variation on find_type_elements that allows you to skip drilling down into children of specific element types . Instead of a single type a list of types can be provided instead to find all types . Unlike find_type_elements this method will always search for nested elements and skip the element types given to nested_except .
def find_type_elements_except(
      type, nested_except = [], elements = @elements
    )
      results = []
      type = [type] if type.instance_of?(Symbol)
      nested_except = [nested_except] if nested_except.instance_of?(Symbol)
      elements.each do |e|
        results.push(e) if type.include?(e.type)
        next if nested_except.include?(e.type) || e.children.empty?
        results.concat(
          find_type_elements_except(type, nested_except, e.children),
        )
      end
      results
    end
def find_type_elements_except ( type , nested_except = [ ] , elements = @elements ) results = [ ] type = [ type ] if type . instance_of? ( Symbol ) nested_except = [ nested_except ] if nested_except . instance_of? ( Symbol ) elements . each do | e | results . push ( e ) if type . include? ( e . type ) next if nested_except . include? ( e . type ) || e . children . empty? results . concat ( find_type_elements_except ( type , nested_except , e . children ) , ) end results end
A variation on find_type_elements that allows you to skip drilling down
into children of specific element types.
A variation on find_type_elements that allows you to skip drilling down into children of specific element types .
type
<not_specific>
nested_except
<not_specific>
elements
<not_specific>