Class: NanDoc::Helpers::NanDocHelpers::TopNav

Inherits:
Object
  • Object
show all
Extended by:
BlockAttrAccessor
Defined in:
lib/nandoc/helpers/top-nav.rb

Instance Attribute Summary collapse

Attributes included from BlockAttrAccessor

#block_attr_accessors

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BlockAttrAccessor

block_attr_accessor, extended

Constructor Details

#initialize(&b) ⇒ TopNav

Returns a new instance of TopNav.



26
27
28
29
30
# File 'lib/nandoc/helpers/top-nav.rb', line 26

def initialize(&b)
  block_attr_accessor_init
  @current_item = @items = @item = nil
  b.call(self)
end

Instance Attribute Details

#bindingObject

Returns the value of attribute binding.



32
33
34
# File 'lib/nandoc/helpers/top-nav.rb', line 32

def binding
  @binding
end

Class Method Details

.home_page(&b) ⇒ Object



42
43
44
# File 'lib/nandoc/helpers/top-nav.rb', line 42

def home_page &b
  @home_page ||= b.call
end

Instance Method Details

#renderObject



33
34
35
36
37
38
39
40
# File 'lib/nandoc/helpers/top-nav.rb', line 33

def render
  item = eval('@item', @binding)
  temdoz = [@current_item_proc.call(item)]
  while item = item.parent
    temdoz.concat [@separator_proc.call, @item_proc.call(item)]
  end
  temdoz.reverse
end