Module: Html2rss::AutoSource::Segmenter::List
- Defined in:
- lib/html2rss/auto_source/segmenter/list.rb
Overview
Builds repeated-list article segments from tag_path frequency (port of Discovery::ListCandidates using tag_path instead of xpath).
Class Method Summary collapse
Class Method Details
.call(segmenter) ⇒ Array<Segment>
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/html2rss/auto_source/segmenter/list.rb', line 15 def call(segmenter) primary = PrimaryLink.new(segmenter) pairs = article_pairs(segmenter) seen = {}.compare_by_identity pairs.each_with_index.filter_map do |(article_tag, selected_anchor), position| next unless seen[article_tag].nil? seen[article_tag] = true link = selected_anchor || primary.select(article_tag) next unless link || segmenter.permit_unanchored Segment.build(root_node: article_tag, primary_link: link, strategy: :list, position:) end end |