Class: Adva::View::Menu::Items
- Inherits:
-
Array
- Object
- Array
- Adva::View::Menu::Items
show all
- Defined in:
- lib/adva/view/menu/items.rb
Instance Method Summary
collapse
Methods inherited from Array
#flatten_once, #flatten_once!
Instance Method Details
#index(text) ⇒ Object
20
21
22
|
# File 'lib/adva/view/menu/items.rb', line 20
def index(text)
each_with_index { |item, ix| return ix if item[0] == text } and nil
end
|
#insert(text, url, options, block) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/adva/view/menu/items.rb', line 5
def insert(text, url, options, block)
item = [text, url, options, block]
if ix = options.delete(:at)
super(ix, item)
elsif ix = index(options.delete(:before))
super(ix, item)
elsif ix = index(options.delete(:after))
super(ix + 1, item)
elsif ix = index(options.delete(:replace))
self[ix] = item
else
push(item)
end
end
|