Class: Bulbasaur::RemoveTags

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

Instance Method Summary collapse

Constructor Details

#initialize(html, banned_tags) ⇒ RemoveTags

Returns a new instance of RemoveTags.



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

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

Instance Method Details

#callObject



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

def call
  parsed_html = Nokogiri::HTML::DocumentFragment.parse @html
  @banned_tags.each { |tag| parsed_html.css(tag).remove }
  parsed_html.to_s
end