Class: Mmmenu::Level
- Inherits:
-
Object
- Object
- Mmmenu::Level
- Defined in:
- lib/mmmenu/level.rb
Instance Method Summary collapse
- #add(title, href, options = {}, &block) ⇒ Object
-
#initialize {|_self| ... } ⇒ Level
constructor
A new instance of Level.
- #to_a ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Level
Returns a new instance of Level.
5 6 7 8 |
# File 'lib/mmmenu/level.rb', line 5 def initialize(&block) @items = [] yield(self) end |
Instance Method Details
#add(title, href, options = {}, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mmmenu/level.rb', line 10 def add(title, href, ={}, &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().merge(children) end |
#to_a ⇒ Object
18 19 20 |
# File 'lib/mmmenu/level.rb', line 18 def to_a @items end |