class SiteDiff::Sanitizer::Regexp::WithSelector

A RegExp with selector.

Public Instance Methods

applies?(_html, node) click to toggle source

Whether the RegExp applies to the given markup.

# File lib/sitediff/sanitize/regexp.rb, line 55
def applies?(_html, node)
  enum_for(:contexts, node).any? { |e| applies_to_string?(e.to_html) }
end
apply(node) click to toggle source

Applies the RegExp to the markup.

# File lib/sitediff/sanitize/regexp.rb, line 61
def apply(node)
  contexts(node) { |e| e.replace(gsub!(e.to_html)) }
end
contexts(node) { |e| ... } click to toggle source

TODO: Document what this method does.

# File lib/sitediff/sanitize/regexp.rb, line 48
def contexts(node)
  selectors = @rule['selector']
  node.css(selectors).each { |e| yield(e) }
end
selector?() click to toggle source

Whether the RegExp has a selector.

# File lib/sitediff/sanitize/regexp.rb, line 42
def selector?
  true
end