Class: SemanticBreadcrumbs

Inherits:
Object
  • Object
show all
Defined in:
lib/semantic-breadcrumbs.rb

Instance Method Summary collapse

Constructor Details

#initialize(divider: '›') ⇒ SemanticBreadcrumbs

Returns a new instance of SemanticBreadcrumbs.



2
3
4
# File 'lib/semantic-breadcrumbs.rb', line 2

def initialize(divider: '')
  @divider = divider
end

Instance Method Details

breadcrumbs takes an array of link hashes and returns HTML markup for breadcrumbs in RDFA format



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/semantic-breadcrumbs.rb', line 8

def breadcrumbs(links)
  bcs = []

  position = 1
  links.each do |link|
    bcs << single(position: position, **symbolize_keys(link))
    position += 1
  end

  return %(<ol class="breadcrumbs" vocab="http://schema.org/" typeof="BreadcrumbList">#{bcs.join(@divider)}</ol>)
end