Module: CrazyHarry::Redact

Included in:
Base
Defined in:
lib/crazy_harry/redact.rb

Defined Under Namespace

Classes: InvalidStripMethod

Constant Summary collapse

STRIP_METHODS =
%w(strip prune escape whitewash)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



8
9
10
# File 'lib/crazy_harry/redact.rb', line 8

def attributes
  @attributes
end

#tagsObject

Returns the value of attribute tags.



8
9
10
# File 'lib/crazy_harry/redact.rb', line 8

def tags
  @tags
end

#unsafeObject

Returns the value of attribute unsafe.



8
9
10
# File 'lib/crazy_harry/redact.rb', line 8

def unsafe
  @unsafe
end

Instance Method Details

#redact!(opts = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/crazy_harry/redact.rb', line 14

def redact!(opts = {})
  self.unsafe       = opts.delete(:unsafe) || opts == {}
  self.tags         = [opts.delete(:tags)].compact.flatten
  self.attributes   = opts.delete(:attributes)
  self.text         = opts.delete(:text)
  self.scope        = opts.delete(:scope)
  prune             = opts.delete(:prune)

  self.steps << strip_unsafe  if self.unsafe
  self.steps << strip_tags    unless prune || self.tags == []
  self.steps << prune_tags    if prune

  run!

  self
end

#strip!Object



10
11
12
# File 'lib/crazy_harry/redact.rb', line 10

def strip!
  fragment.to_text
end