Class: Html2rss::AutoSource::Discovery::ListCandidates
- Inherits:
-
Object
- Object
- Html2rss::AutoSource::Discovery::ListCandidates
- Defined in:
- lib/html2rss/auto_source/discovery/list_candidates.rb
Overview
Builds repeated-list article container candidates from generic HTML.
Class Method Summary collapse
-
.simplify_xpath(xpath) ⇒ String
Simplify an XPath selector by removing index notation.
Instance Method Summary collapse
- #each_article_tag(anchor_filter:, boundary_condition:) {|article_tag, selected_anchor| ... } ⇒ Enumerator
-
#initialize(parsed_body, minimum_selector_frequency:, use_top_selectors:) ⇒ ListCandidates
constructor
A new instance of ListCandidates.
Constructor Details
#initialize(parsed_body, minimum_selector_frequency:, use_top_selectors:) ⇒ ListCandidates
Returns a new instance of ListCandidates.
21 22 23 24 25 |
# File 'lib/html2rss/auto_source/discovery/list_candidates.rb', line 21 def initialize(parsed_body, minimum_selector_frequency:, use_top_selectors:) @parsed_body = parsed_body @minimum_selector_frequency = minimum_selector_frequency @use_top_selectors = use_top_selectors end |
Class Method Details
.simplify_xpath(xpath) ⇒ String
Simplify an XPath selector by removing index notation.
14 15 16 |
# File 'lib/html2rss/auto_source/discovery/list_candidates.rb', line 14 def self.simplify_xpath(xpath) xpath.gsub(/\[\d+\]/, '') end |
Instance Method Details
#each_article_tag(anchor_filter:, boundary_condition:) {|article_tag, selected_anchor| ... } ⇒ Enumerator
33 34 35 36 37 |
# File 'lib/html2rss/auto_source/discovery/list_candidates.rb', line 33 def each_article_tag(anchor_filter:, boundary_condition:) return enum_for(:each_article_tag, anchor_filter:, boundary_condition:) unless block_given? (anchor_filter:, boundary_condition:).each { yield _1[:article_tag], _1[:selected_anchor] } end |