Class: Interview::NavigationItem

Inherits:
Link show all
Defined in:
lib/interview/controls/navigation_item.rb

Instance Attribute Summary collapse

Attributes inherited from Link

#action, #assoc_object, #caption, #hint, #http_method, #image, #nested_resource, #new_site, #object, #options, #style, #url, #url_params

Attributes included from HasHtmlOptions

#html_class, #html_options

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods inherited from Link

#initialize

Methods included from HasHtmlOptions

#initialize

Methods included from NestedBuildable

#create_nested_builder, #render_nested_builder

Methods inherited from Control

#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Constructor Details

This class inherits a constructor from Interview::Link

Instance Attribute Details

#activeObject

Returns the value of attribute active.



4
5
6
# File 'lib/interview/controls/navigation_item.rb', line 4

def active
  @active
end

#badge_formulaObject

Returns the value of attribute badge_formula.



4
5
6
# File 'lib/interview/controls/navigation_item.rb', line 4

def badge_formula
  @badge_formula
end

#levelObject

Returns the value of attribute level.



4
5
6
# File 'lib/interview/controls/navigation_item.rb', line 4

def level
  @level
end

Instance Method Details

#build(b) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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