class Interview::NavigationItem

Attributes

active[RW]
badge_formula[RW]
level[RW]

Public Instance Methods

build(b) { || ... } click to toggle source
Calls superclass method Interview::Link#build
# File lib/interview/controls/navigation_item.rb, line 6
def build(b)
  set_level
  html_class = ["level#{@level}"]
  html_class << 'active' if @active
  b.section style: 'li', html_class: html_class do
    super(b) do
      badge = @badge_formula.call if @badge_formula 
      unless badge.nil? or badge == 0 or badge == ''
        b.text text: badge.to_s, style: 'span', html_class: 'badge pull-right'
      end
    end
  end
  yield if block_given?
end

Protected Instance Methods

set_level() click to toggle source
# File lib/interview/controls/navigation_item.rb, line 23
def set_level
  return if @level
  if level = find_attribute(:level)
    @level = level + 1
  else
    @level = 0
  end
end