Class: ReeText::PermitScrubber
- Inherits:
-
Loofah::Scrubber
- Object
- Loofah::Scrubber
- ReeText::PermitScrubber
- Includes:
- Ree::LinkDSL
- Defined in:
- lib/ree_lib/packages/ree_text/package/ree_text/scrubbers/permit_scrubber.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#prune ⇒ Object
readonly
Returns the value of attribute prune.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(prune: false, tags: nil, attributes: nil) ⇒ PermitScrubber
constructor
A new instance of PermitScrubber.
- #scrub(node) ⇒ Object
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 = @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (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 |
#prune ⇒ Object (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 |
#tags ⇒ Object (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 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 |