Module: Html2rss::Html::CardWalk
- Defined in:
- lib/html2rss/html/card_walk.rb
Overview
Leftover parent-card walk policy shared by Nokogiri and SST extractors. Adapters traverse; this module decides miss / thin wrapper / crowded abort. Keep/drop stays on ArticleRules::Description. Capture's selector lift is a separate job (set-aware abort) and is not encoded here.
Class Method Summary collapse
-
.crowded?(heading_count:, distinct_main_hrefs:) ⇒ Boolean
True when the parent looks like a listing, not one card.
-
.miss?(heading_or_anchor_item:, published_at:, description:) ⇒ Boolean
Whether to climb to a parent card.
-
.thin_wrapper?(children:, item:, descendant_of:) ⇒ Boolean
True when the parent only wraps the item (no sibling content).
Class Method Details
.crowded?(heading_count:, distinct_main_hrefs:) ⇒ Boolean
Returns true when the parent looks like a listing, not one card.
36 37 38 |
# File 'lib/html2rss/html/card_walk.rb', line 36 def crowded?(heading_count:, distinct_main_hrefs:) heading_count > 1 || distinct_main_hrefs > 1 end |
.miss?(heading_or_anchor_item:, published_at:, description:) ⇒ Boolean
Returns whether to climb to a parent card.
17 18 19 |
# File 'lib/html2rss/html/card_walk.rb', line 17 def miss?(heading_or_anchor_item:, published_at:, description:) heading_or_anchor_item && published_at.nil? && description.nil? end |
.thin_wrapper?(children:, item:, descendant_of:) ⇒ Boolean
Returns true when the parent only wraps the item (no sibling content).
26 27 28 29 30 |
# File 'lib/html2rss/html/card_walk.rb', line 26 def thin_wrapper?(children:, item:, descendant_of:) children.none? do |child| !child.equal?(item) && !descendant_of.call(item, child) end end |