Methods

FeedNormalizer::ElementCleaner

Public Instance Methods

clean!() click to toggle source

Recursively cleans all elements in place.

Only allow tags in whitelist. Always parse the html with a parser and delete all tags that arent on the list.

For feed elements that can contain HTML:

  • feed.(title|description)

  • feed.entries.(title|description|content)

# File lib/structures.rb, line 100
def clean!
  self.class::SIMPLE_ELEMENTS.each do |element|
    val = self.send(element)

    send("#{element}=", (val.is_a?(Array) ?
      val.collect{|v| HtmlCleaner.flatten(v.to_s)} : HtmlCleaner.flatten(val.to_s)))
  end

  self.class::HTML_ELEMENTS.each do |element|
    send("#{element}=", HtmlCleaner.clean(self.send(element).to_s))
  end

  self.class::BLENDED_ELEMENTS.each do |element|
    self.send(element).collect{|v| v.clean!}
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.