Class: SiteDiff::Sanitizer::Regexp
- Inherits:
-
Object
- Object
- SiteDiff::Sanitizer::Regexp
- Defined in:
- lib/sitediff/sanitize/regexp.rb
Overview
Regular Expression Object.
Direct Known Subclasses
Defined Under Namespace
Classes: WithSelector
Class Method Summary collapse
-
.create(rule) ⇒ Object
Creates a RegExp object as per rule.
Instance Method Summary collapse
-
#applies?(html, _node) ⇒ Boolean
Whether the RegExp applies to the given markup.
-
#apply(html) ⇒ Object
Applies the RegExp to the markup.
-
#initialize(rule) ⇒ Regexp
constructor
Creates a RegExp object.
-
#selector? ⇒ Boolean
Whether the RegExp has a selector.
Constructor Details
#initialize(rule) ⇒ Regexp
Creates a RegExp object.
9 10 11 |
# File 'lib/sitediff/sanitize/regexp.rb', line 9 def initialize(rule) @rule = rule end |
Class Method Details
.create(rule) ⇒ Object
Creates a RegExp object as per rule.
33 34 35 |
# File 'lib/sitediff/sanitize/regexp.rb', line 33 def self.create(rule) rule['selector'] ? WithSelector.new(rule) : new(rule) end |
Instance Method Details
#applies?(html, _node) ⇒ Boolean
Whether the RegExp applies to the given markup.
21 22 23 |
# File 'lib/sitediff/sanitize/regexp.rb', line 21 def applies?(html, _node) applies_to_string?(html) end |
#apply(html) ⇒ Object
Applies the RegExp to the markup.
27 28 29 |
# File 'lib/sitediff/sanitize/regexp.rb', line 27 def apply(html) gsub!(html) end |
#selector? ⇒ Boolean
Whether the RegExp has a selector.
15 16 17 |
# File 'lib/sitediff/sanitize/regexp.rb', line 15 def selector? false end |