Class: Marsdawn::Site::Breadcrumb

Inherits:
Hash
  • Object
show all
Defined in:
lib/marsdawn/site/breadcrumb.rb

Instance Method Summary collapse

Constructor Details

#initialize(site, crumb) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.



6
7
8
9
10
11
# File 'lib/marsdawn/site/breadcrumb.rb', line 6

def initialize site, crumb
  @site = site
  crumb.each do |path|
    self[path] = Marsdawn::Site::Link.new(@site, path)
  end
end

Instance Method Details

#to_htmlObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/marsdawn/site/breadcrumb.rb', line 17

def to_html
  words = []
  if self.size > 0
    words << '<ul>'
    self.each do |uri, link|
      words << "<li>#{link.to_html}</li>"
    end
    words << '</ul>'
  end
  words.join('')
end

#to_sObject



13
14
15
# File 'lib/marsdawn/site/breadcrumb.rb', line 13

def to_s
  to_html
end