Class: NavigationMenu
- Inherits:
-
Object
- Object
- NavigationMenu
- Defined in:
- lib/dti-navigation-menu/lib/dti-navigation-menu.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
Returns the value of attribute href.
-
#items ⇒ Object
Returns the value of attribute items.
-
#markup_classes ⇒ Object
Returns the value of attribute markup_classes.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #descendents? ⇒ Boolean
- #each(&block) ⇒ Object
-
#initialize(title, i_href = nil, markup_classes = nil, &block) ⇒ NavigationMenu
constructor
A new instance of NavigationMenu.
- #item(title, i_href = nil, markup_classes = nil, &block) ⇒ Object
- #link_id ⇒ Object
Constructor Details
#initialize(title, i_href = nil, markup_classes = nil, &block) ⇒ NavigationMenu
Returns a new instance of NavigationMenu.
4 5 6 7 8 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 4 def initialize(title, i_href = nil, markup_classes = nil, &block) @title, @href, @markup_classes = title, i_href, markup_classes @items = [] block.call(self) if block end |
Instance Attribute Details
#href ⇒ Object
Returns the value of attribute href.
2 3 4 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 2 def href @href end |
#items ⇒ Object
Returns the value of attribute items.
2 3 4 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 2 def items @items end |
#markup_classes ⇒ Object
Returns the value of attribute markup_classes.
2 3 4 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 2 def markup_classes @markup_classes end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 2 def title @title end |
Instance Method Details
#descendents? ⇒ Boolean
20 21 22 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 20 def descendents? (@items.length > 0) ? true : false end |
#each(&block) ⇒ Object
16 17 18 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 16 def each(&block) @items.each(&block) end |
#item(title, i_href = nil, markup_classes = nil, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 10 def item(title, i_href = nil, markup_classes = nil, &block) = NavigationMenu.new title, i_href, markup_classes block.call if block @items << end |
#link_id ⇒ Object
24 25 26 |
# File 'lib/dti-navigation-menu/lib/dti-navigation-menu.rb', line 24 def link_id @title.downcase.gsub(/[^a-z0-9 ]/i,'').tr(' ','_').gsub(/[\_]{2,}/,'_') end |