class ArticleFixtureGen::Data::ParentElementFor

Given a parent element and an array of integers which fully specify the DOM position of a node (or element, really), walk the DOM from the given parent to find the element which contains a node at the specified point below that parent. This is to work around the fact that Ox maintains no links between a node (or element) with its parent.

Public Class Methods

call(parent, dom_pos_indexes) click to toggle source
# File lib/article_fixture_gen/data/parent_element_for.rb, line 11
def self.call(parent, dom_pos_indexes)
  el = parent
  dom_pos_indexes[0..-2].each { |index| el = el.nodes[index] }
  el
end