# frozen_string_literal: true module ArticleFixtureGen module Data # 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. class ParentElementFor def self.call(parent, dom_pos_indexes) el = parent dom_pos_indexes[0..-2].each { |index| el = el.nodes[index] } el end end # class ArticleFixtureGen::Data::ParentElementFor end end