Class: RailsMenu::Set
- Inherits:
-
Object
- Object
- RailsMenu::Set
- Defined in:
- lib/rails_menu/set.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #add(id, url = '', options = {}) ⇒ Object
- #elements ⇒ Object
-
#initialize(name = 'default', element_list = []) ⇒ Set
constructor
A new instance of Set.
Constructor Details
#initialize(name = 'default', element_list = []) ⇒ Set
Returns a new instance of Set.
16 17 18 19 20 21 22 |
# File 'lib/rails_menu/set.rb', line 16 def initialize(name = 'default', element_list = []) @name = name @element_list = [] element_list.each{ |elem| self.add(*elem) } self.class.list[name] = self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/rails_menu/set.rb', line 14 def name @name end |
Class Method Details
.[](list_name) ⇒ Object
9 10 11 |
# File 'lib/rails_menu/set.rb', line 9 def [](list_name) list[list_name] end |
.list ⇒ Object
5 6 7 |
# File 'lib/rails_menu/set.rb', line 5 def list @list ||= {} end |
Instance Method Details
#add(id, url = '', options = {}) ⇒ Object
24 25 26 27 28 |
# File 'lib/rails_menu/set.rb', line 24 def add(id, url = '', = {}) element = Element.new(id.to_s, url, ) @element_list << element element end |
#elements ⇒ Object
30 31 32 |
# File 'lib/rails_menu/set.rb', line 30 def elements @element_list end |