Method: Html2rss::AutoSource::Scraper::SemanticHtml.find_tag_in_ancestors
- Defined in:
- lib/html2rss/auto_source/scraper/semantic_html.rb
.find_tag_in_ancestors(current_tag, tag_name, stop_tag: 'html') ⇒ Nokogiri::XML::Node
Finds the closest ancestor tag matching the specified tag name
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/html2rss/auto_source/scraper/semantic_html.rb', line 50 def self.find_tag_in_ancestors(current_tag, tag_name, stop_tag: 'html') return current_tag if current_tag.name == tag_name = Set[tag_name, stop_tag] while current_tag.respond_to?(:parent) && !.member?(current_tag.name) current_tag = current_tag.parent end current_tag end |