Class: Html2rss::HtmlExtractor::IdGenerator
- Inherits:
-
Object
- Object
- Html2rss::HtmlExtractor::IdGenerator
- Defined in:
- lib/html2rss/html_extractor/id_generator.rb
Overview
IdGenerator determines the unique ID for an article container node.
Class Method Summary collapse
-
.call(article_tag, heading:, url:, selected_anchor:, fallback_anchorless:) ⇒ String?
The generated ID, if any.
Class Method Details
.call(article_tag, heading:, url:, selected_anchor:, fallback_anchorless:) ⇒ String?
Returns the generated ID, if any.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/html2rss/html_extractor/id_generator.rb', line 18 def call(article_tag, heading:, url:, selected_anchor:, fallback_anchorless:) id_from_dom = parse_id_from_dom(article_tag, url, selected_anchor) return id_from_dom if id_from_dom heading_text = resolve_heading_text(article_tag, heading, fallback_anchorless) if heading_text && !heading_text.strip.empty? generate_slug(heading_text) elsif fallback_anchorless generate_content_hash(article_tag) end end |