Class: Html2rss::AutoSource::Scraper::LinkHeuristics::PostSuffixClassifier

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/auto_source/scraper/link_heuristics.rb

Overview

Classifies whether the final segment is a strong post-like suffix.

Instance Method Summary collapse

Constructor Details

#initialize(segments) ⇒ PostSuffixClassifier

Returns a new instance of PostSuffixClassifier.

Parameters:

  • segments (Array<String>)

    normalized URL path segments



375
376
377
# File 'lib/html2rss/auto_source/scraper/link_heuristics.rb', line 375

def initialize(segments)
  @segments = segments
end

Instance Method Details

#strong?Boolean

Returns true when the final path segment looks like a post slug.

Returns:

  • (Boolean)

    true when the final path segment looks like a post slug



380
381
382
383
384
# File 'lib/html2rss/auto_source/scraper/link_heuristics.rb', line 380

def strong?
  @segments.any? &&
    included_last_segment? &&
    LeadingSegments.new(@segments).trusted_post_context?
end