Class: ReeText::PermitScrubber

Inherits:
Loofah::Scrubber
  • Object
show all
Includes:
Ree::LinkDSL
Defined in:
lib/ree_lib/packages/ree_text/package/ree_text/scrubbers/permit_scrubber.rb

Direct Known Subclasses

TargetScrubber

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prune: false, tags: nil, attributes: nil) ⇒ PermitScrubber

Returns a new instance of PermitScrubber.



17
18
19
20
21
22
# File 'lib/ree_lib/packages/ree_text/package/ree_text/scrubbers/permit_scrubber.rb', line 17

def initialize(prune: false, tags: nil, attributes: nil)
  @prune = prune
  @direction = @prune ? :top_down : :bottom_up
  @tags = tags
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/ree_lib/packages/ree_text/package/ree_text/scrubbers/permit_scrubber.rb', line 10

def attributes
  @attributes
end

#pruneObject (readonly)

Returns the value of attribute prune.



10
11
12
# File 'lib/ree_lib/packages/ree_text/package/ree_text/scrubbers/permit_scrubber.rb', line 10

def prune
  @prune
end

#tagsObject (readonly)

Returns the value of attribute tags.



10
11
12
# File 'lib/ree_lib/packages/ree_text/package/ree_text/scrubbers/permit_scrubber.rb', line 10

def tags
  @tags
end

Instance Method Details

#scrub(node) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ree_lib/packages/ree_text/package/ree_text/scrubbers/permit_scrubber.rb', line 25

def scrub(node)
  if node.cdata?
    text = node.document.create_text_node(node.text)
    node.replace(text)

    return CONTINUE
  end

  return CONTINUE if node.text?

  unless (node.element? || node.comment?) && allowed_node?(node)
    return STOP if scrub_node(node) == STOP
  end

  scrub_attributes(node)
end