Class: Bulbasaur::RemoveAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/bulbasaur/removals/remove_attributes.rb

Instance Method Summary collapse

Constructor Details

#initialize(html, banned_attrs) ⇒ RemoveAttributes



3
4
5
6
# File 'lib/bulbasaur/removals/remove_attributes.rb', line 3

def initialize(html, banned_attrs)
  @html = html
  @banned_attrs = banned_attrs
end

Instance Method Details

#callObject



8
9
10
11
12
# File 'lib/bulbasaur/removals/remove_attributes.rb', line 8

def call
  parsed_html = Nokogiri::HTML::DocumentFragment.parse @html
  @banned_attrs.each { |attr| parsed_html.xpath(".//@#{attr}").remove }
  parsed_html.to_s
end