Class: PartialMenu::MenuItem
- Inherits:
-
Object
- Object
- PartialMenu::MenuItem
- 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.
-
#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
- #active? ⇒ Boolean
-
#initialize(props, parent) ⇒ MenuItem
constructor
A new instance of MenuItem.
- #separator? ⇒ Boolean
- #setup ⇒ Object
- #submenu? ⇒ Boolean
Constructor Details
#initialize(props, parent) ⇒ MenuItem
Returns a new instance of MenuItem.
11 12 13 14 15 16 17 18 19 |
# File 'lib/partial_menu/menu_item.rb', line 11 def initialize(props, parent) raise 'Expected a hash as props' unless props.is_a?(Hash) raise 'Expected a PartialMenu::Menu as parent' unless parent.is_a?( PartialMenu::Menu ) @parent = parent @props = props setup end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/partial_menu/menu_item.rb', line 9 def id @id end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'lib/partial_menu/menu_item.rb', line 5 def parent @parent end |
#submenu ⇒ Object (readonly)
Returns the value of attribute submenu.
8 9 10 |
# File 'lib/partial_menu/menu_item.rb', line 8 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/partial_menu/menu_item.rb', line 7 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/partial_menu/menu_item.rb', line 4 def type @type end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/partial_menu/menu_item.rb', line 6 def uri @uri end |
Instance Method Details
#active? ⇒ Boolean
38 39 40 |
# File 'lib/partial_menu/menu_item.rb', line 38 def active? false end |
#separator? ⇒ Boolean
34 35 36 |
# File 'lib/partial_menu/menu_item.rb', line 34 def separator? @type == :separator end |
#setup ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/partial_menu/menu_item.rb', line 21 def setup set_type set_title set_id set_uri set_other_attr end |
#submenu? ⇒ Boolean
30 31 32 |
# File 'lib/partial_menu/menu_item.rb', line 30 def != nil end |