Class: SiteDiff::Sanitizer::Regexp

Inherits:
Object
  • Object
show all
Defined in:
lib/sitediff/sanitize/regexp.rb

Direct Known Subclasses

WithSelector

Defined Under Namespace

Classes: WithSelector

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule) ⇒ Regexp

Returns a new instance of Regexp.



6
7
8
# File 'lib/sitediff/sanitize/regexp.rb', line 6

def initialize(rule)
  @rule = rule
end

Class Method Details

.create(rule) ⇒ Object



22
23
24
# File 'lib/sitediff/sanitize/regexp.rb', line 22

def self.create(rule)
  rule['selector'] ? WithSelector.new(rule) : new(rule)
end

Instance Method Details

#applies?(html, _node) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/sitediff/sanitize/regexp.rb', line 14

def applies?(html, _node)
  applies_to_string?(html)
end

#apply(html) ⇒ Object



18
19
20
# File 'lib/sitediff/sanitize/regexp.rb', line 18

def apply(html)
  gsub!(html)
end

#selector?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/sitediff/sanitize/regexp.rb', line 10

def selector?
  false
end