module HtmlElement::Utils

Public Class Methods

collect_elements(tree) { |elm| ... } click to toggle source
# File lib/htmlelement/utils.rb, line 8
def self.collect_elements(tree)
  [].tap do |elms|
    tree.traverse do |elm|
      matched = yield elm
      elms.push elm if matched
    end
  end
end
collect_elements_by_name(tree, name) click to toggle source
# File lib/htmlelement/utils.rb, line 17
def self.collect_elements_by_name(tree, name)
  collect_elements(tree) do |elm|
    elm.kind_of? HtmlElement and elm.tagname == name
  end
end