Class: Slimmer::Processors::SectionInserter

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

Instance Method Summary collapse

Constructor Details

#initialize(artefact) ⇒ SectionInserter

Returns a new instance of SectionInserter.



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

def initialize(artefact)
  @artefact = artefact
end

Instance Method Details

#filter(src, dest) ⇒ Object



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

def filter(src, dest)
  if @artefact and (list = dest.at_css('#global-breadcrumb ol'))
    if (section = @artefact.primary_section)
      sections = recurse_sections(section)
      current = sections.pop
      sections.each do |section|
        append_tag(list, section)
      end
      append_tag(list, current, :strong => true)
    end
  end
end