Class: Bulbasaur::RemoveAttributes
- Inherits:
-
Object
- Object
- Bulbasaur::RemoveAttributes
- Defined in:
- lib/bulbasaur/removals/remove_attributes.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(html, banned_attrs) ⇒ RemoveAttributes
constructor
A new instance of RemoveAttributes.
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
#call ⇒ Object
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 |