Module: Html2rss::Html::ArticleRules::Category
- Defined in:
- lib/html2rss/html/article_rules/category.rb
Overview
Shared category term vocabulary and text accumulation (DOM walk stays in adapters).
Constant Summary collapse
- CATEGORY_TERMS =
Class/data attribute tokens that mark category metadata.
%w[ category categories tag tags topic topics section sections label labels theme themes subject subjects ].freeze
- CATEGORY_ATTR_PATTERN =
Regex matching category-related attribute or class names.
/#{CATEGORY_TERMS.join('|')}/i
Class Method Summary collapse
- .add_split_text!(categories, text) ⇒ void
- .add_text!(categories, text) ⇒ void
- .attr_name_match?(name) ⇒ Boolean
- .class_match?(class_attr) ⇒ Boolean
Class Method Details
.add_split_text!(categories, text) ⇒ void
This method returns an undefined value.
46 47 48 49 50 |
# File 'lib/html2rss/html/article_rules/category.rb', line 46 def add_split_text!(categories, text) return unless text text.split(/\n+/).each { |line| add_text!(categories, line) } end |
.add_text!(categories, text) ⇒ void
This method returns an undefined value.
37 38 39 40 |
# File 'lib/html2rss/html/article_rules/category.rb', line 37 def add_text!(categories, text) value = text.to_s.strip categories.add(value) unless value.empty? end |
.attr_name_match?(name) ⇒ Boolean
22 23 24 |
# File 'lib/html2rss/html/article_rules/category.rb', line 22 def attr_name_match?(name) name.to_s.match?(CATEGORY_ATTR_PATTERN) end |
.class_match?(class_attr) ⇒ Boolean
29 30 31 |
# File 'lib/html2rss/html/article_rules/category.rb', line 29 def class_match?(class_attr) class_attr.to_s.match?(CATEGORY_ATTR_PATTERN) end |