Class: PartialMenu::Menu
- Inherits:
-
Object
- Object
- PartialMenu::Menu
- Defined in:
- lib/partial_menu/menu.rb
Overview
Represents a menu with menu items
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(props, type = 'main', parent = nil) ⇒ Menu
constructor
A new instance of Menu.
Constructor Details
#initialize(props, type = 'main', parent = nil) ⇒ Menu
Returns a new instance of Menu.
11 12 13 14 15 16 17 18 19 |
# File 'lib/partial_menu/menu.rb', line 11 def initialize(props, type = 'main', parent = nil) raise "Expected a array but got #{props.class}" unless props.is_a? Array raise "Expected a string but got #{type.class}" unless type.is_a? String @type = type @items = [] @parent = parent set_id add_items(props) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/partial_menu/menu.rb', line 9 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/partial_menu/menu.rb', line 7 def items @items end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
8 9 10 |
# File 'lib/partial_menu/menu.rb', line 8 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/partial_menu/menu.rb', line 6 def type @type end |