Sha256: 30010d043a435ed4c1668fb0755f50138141791511b1d769e3f35dc7c669864c

Contents?: true

Size: 678 Bytes

Versions: 4

Compression:

Stored size: 678 Bytes

Contents

class NavigationMenu
  attr_accessor :title, :href, :items, :markup_classes
  
  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

  def item(title, i_href = nil, markup_classes = nil, &block)
    menu_item = NavigationMenu.new title, i_href, markup_classes
    block.call menu_item if block
    @items << menu_item
  end
  
  def each(&block)
    @items.each(&block)
  end

  def descendents?
    (@items.length > 0) ? true : false
  end
  
  def link_id
    @title.downcase.gsub(/[^a-z0-9 ]/i,'').tr(' ','_').gsub(/[\_]{2,}/,'_')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brisk-bills-0.8.2 lib/dti-navigation-menu/lib/dti-navigation-menu.rb
brisk-bills-0.8.1 lib/dti-navigation-menu/lib/dti-navigation-menu.rb
brisk-bills-0.7.0 lib/dti-navigation-menu/lib/dti-navigation-menu.rb
brisk-bills-0.6.0 lib/dti-navigation-menu/lib/dti-navigation-menu.rb