Class: PartialMenu::MenuItem
- Inherits:
-
Object
- Object
- PartialMenu::MenuItem
- Includes:
- ActiveLinkTo
- Defined in:
- lib/partial_menu/menu_item.rb
Overview
Represents menu item in a menu
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#submenu ⇒ Object
readonly
Returns the value of attribute submenu.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(props, parent) ⇒ MenuItem
constructor
Contructor which check parameter types and start setup.
-
#separator? ⇒ Boolean
True if menu item is a separator.
-
#submenu? ⇒ boolean
True if menu item has submenu.
Constructor Details
#initialize(props, parent) ⇒ MenuItem
Contructor which check parameter types and start setup
Throws ArgumentError if parameters are not expected type
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/partial_menu/menu_item.rb', line 24 def initialize(props, parent) unless props.is_a? Hash raise ::ArgumentError, "Expected Hash, got #{prop.class}" end unless parent.is_a? PartialMenu::Menu raise ::ArgumentError, "Expected PartialMenu::Menu, got #{parent.class}" end @parent = parent @props = props setup end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/partial_menu/menu_item.rb', line 13 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/partial_menu/menu_item.rb', line 14 def @options end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/partial_menu/menu_item.rb', line 9 def parent @parent end |
#submenu ⇒ Object (readonly)
Returns the value of attribute submenu.
12 13 14 |
# File 'lib/partial_menu/menu_item.rb', line 12 def @submenu end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/partial_menu/menu_item.rb', line 11 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/partial_menu/menu_item.rb', line 8 def type @type end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
10 11 12 |
# File 'lib/partial_menu/menu_item.rb', line 10 def uri @uri end |
Instance Method Details
#separator? ⇒ Boolean
True if menu item is a separator
@ return [boolean]
50 51 52 |
# File 'lib/partial_menu/menu_item.rb', line 50 def separator? @type == :separator end |
#submenu? ⇒ boolean
True if menu item has submenu
41 42 43 |
# File 'lib/partial_menu/menu_item.rb', line 41 def @submenu != nil end |