Class: Html2rss::HtmlExtractor::SemanticAnchorCandidates::Score
- Inherits:
-
Object
- Object
- Html2rss::HtmlExtractor::SemanticAnchorCandidates::Score
- Defined in:
- lib/html2rss/html_extractor/semantic_anchor_candidates.rb
Overview
Scores an eligible semantic anchor candidate.
Constant Summary collapse
- RULES =
Score weights keyed by candidate signal predicate.
{ heading_anchor?: 100, heading_text_match?: 20, meaningful_text?: 10, content_like_destination?: 10 }.freeze
Instance Method Summary collapse
-
#initialize(candidate) ⇒ Score
constructor
A new instance of Score.
-
#value ⇒ Integer
Ranking score.
Constructor Details
#initialize(candidate) ⇒ Score
Returns a new instance of Score.
196 197 198 |
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 196 def initialize(candidate) @candidate = candidate end |
Instance Method Details
#value ⇒ Integer
Returns ranking score.
201 202 203 |
# File 'lib/html2rss/html_extractor/semantic_anchor_candidates.rb', line 201 def value RULES.sum { |predicate, weight| @candidate.public_send(predicate) ? weight : 0 } end |