Class: Html2rss::HtmlExtractor::SemanticAnchorCandidates
- Inherits:
-
Object
- Object
- Html2rss::HtmlExtractor::SemanticAnchorCandidates
- Defined in:
- lib/html2rss/html_extractor/semantic_anchor_candidates.rb
Overview
Builds ranked anchor facts for one semantic content container.
Defined Under Namespace
Classes: AnchorFacts, Candidate, Context, DestinationWinners, Score
Instance Method Summary collapse
-
#initialize(container, link_heuristics:) ⇒ SemanticAnchorCandidates
constructor
A new instance of SemanticAnchorCandidates.
-
#to_a ⇒ Array<AnchorFacts>
Strongest candidate per destination.
Constructor Details
#initialize(container, link_heuristics:) ⇒ SemanticAnchorCandidates
Returns a new instance of SemanticAnchorCandidates.
235 236 237 238 |
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 235 def initialize(container, link_heuristics:) @container = container @context = Context.new(container, link_heuristics:) end |
Instance Method Details
#to_a ⇒ Array<AnchorFacts>
Returns strongest candidate per destination.
241 242 243 244 245 |
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 241 def to_a @container.css(HtmlExtractor::MAIN_ANCHOR_SELECTOR) .each_with_object(DestinationWinners.new) { |anchor, winners| add_anchor(anchor, winners) } .to_a end |