Class: NanDoc::Helpers::NanDocHelpers::MenuBouncy Private

Inherits:
Object
  • Object
show all
Includes:
StringMethods
Defined in:
lib/nandoc/helpers/menu-bouncy.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StringMethods

#basename_no_extension, #indent, #no_blank_lines, #no_leading_ws, #no_trailing_ws, oxford_comma, #quoted, #reindent, #unindent

Constructor Details

#initialize(binding, &block) ⇒ MenuBouncy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MenuBouncy.



22
23
24
25
26
27
28
# File 'lib/nandoc/helpers/menu-bouncy.rb', line 22

def initialize(binding, &block)
  @separator_default = '>'
  @tab = '  '
  @tabs = 0
  @item = eval('@item', binding)
  block.call(self)
end

Instance Attribute Details

#separator_defaultObject Also known as: separator, menu_item_bullet_right

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/nandoc/helpers/menu-bouncy.rb', line 29

def separator_default
  @separator_default
end

#tabObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/nandoc/helpers/menu-bouncy.rb', line 29

def tab
  @tab
end

#tabsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/nandoc/helpers/menu-bouncy.rb', line 29

def tabs
  @tabs
end

Instance Method Details

#renderObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/nandoc/helpers/menu-bouncy.rb', line 33

def render
  item = @item
  chunks = []
  if item.nandoc_sorted_visible_children.any?
    chunks.push render_branch(item)
  else
    chunks.push render_leaf(item)
  end
  while item = item.parent
    chunks.push render_branch(item)
  end
  html = chunks.reverse.join('')
  html2 = reindent html
  html2.strip
end