Class: Slimmer::Processors::SearchRemover

Inherits:
Object
  • Object
show all
Defined in:
lib/slimmer/processors/search_remover.rb

Instance Method Summary collapse

Constructor Details

#initialize(headers) ⇒ SearchRemover

Returns a new instance of SearchRemover.



3
4
5
# File 'lib/slimmer/processors/search_remover.rb', line 3

def initialize(headers)
  @headers = headers
end

Instance Method Details

#filter(_src, dest) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/slimmer/processors/search_remover.rb', line 7

def filter(_src, dest)
  if @headers.include?(Slimmer::Headers::REMOVE_SEARCH_HEADER)
    search = dest.at_css("#global-header #search")
    search.remove if search

    search_link = dest.at_css("#global-header .search-toggle")
    search_link.remove if search_link

    gem_search = dest.at_css(".gem-c-layout-header__search")
    gem_search.remove if gem_search
  end
end