class Mmmenu::Level

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/mmmenu/level.rb, line 5
def initialize(&block)
  @items = []
  yield(self)
end

Public Instance Methods

add(title, href, options={}, &block) click to toggle source
# File lib/mmmenu/level.rb, line 10
def add(title, href, options={}, &block)
  children = {}
  if block_given? # which means current item has children
    children = { :children => self.class.new(&block).to_a }
  end
  @items << { :title => title, :href => href }.merge(options).merge(children)
end
to_a() click to toggle source
# File lib/mmmenu/level.rb, line 18
def to_a
  @items
end